Merge branch '2158-threadsanitizer-data-race-in-memmove' into 'main'

Resolve "ThreadSanitizer: data race in memmove"

Closes #2158

See merge request isc-projects/bind9!4149
This commit is contained in:
Mark Andrews 2020-09-21 09:18:35 +00:00
commit 2430dff4ba

View file

@ -2636,7 +2636,8 @@ deletefromlevel(dns_rbtnode_t *item, dns_rbtnode_t **rootp) {
*/
child = LEFT(item);
} else {
dns_rbtnode_t holder, *tmp = &holder;
dns_rbtnode_t *saved_parent, *saved_right;
int saved_color;
/*
* This node has two children, so it cannot be directly
@ -2672,7 +2673,9 @@ deletefromlevel(dns_rbtnode_t *item, dns_rbtnode_t **rootp) {
* information, which will be needed when linking up
* delete to the successor's old location.
*/
memmove(tmp, successor, sizeof(dns_rbtnode_t));
saved_parent = PARENT(successor);
saved_right = RIGHT(successor);
saved_color = COLOR(successor);
if (IS_ROOT(item)) {
*rootp = successor;
@ -2698,28 +2701,27 @@ deletefromlevel(dns_rbtnode_t *item, dns_rbtnode_t **rootp) {
/*
* Now relink the node to be deleted into the
* successor's previous tree location. PARENT(tmp)
* is the successor's original parent.
* successor's previous tree location.
*/
INSIST(!IS_ROOT(item));
if (PARENT(tmp) == item) {
if (saved_parent == item) {
/*
* Node being deleted was successor's parent.
*/
RIGHT(successor) = item;
PARENT(item) = successor;
} else {
LEFT(PARENT(tmp)) = item;
PARENT(item) = PARENT(tmp);
LEFT(saved_parent) = item;
PARENT(item) = saved_parent;
}
/*
* Original location of successor node has no left.
*/
LEFT(item) = NULL;
RIGHT(item) = RIGHT(tmp);
COLOR(item) = COLOR(tmp);
RIGHT(item) = saved_right;
COLOR(item) = saved_color;
}
/*