]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Ignore TSAN errors accessing init_count and header->count
authorMark Andrews <marka@isc.org>
Thu, 15 Oct 2020 06:03:35 +0000 (17:03 +1100)
committerMark Andrews <marka@isc.org>
Thu, 10 Dec 2020 06:31:19 +0000 (06:31 +0000)
    WARNING: ThreadSanitizer: data race
    Write of size 4 at 0x000000000001 by thread T1 (mutexes: write M1):
    #0 subtractrdataset lib/dns/rbtdb.c:7065:21
    #1 dns_db_subtractrdataset lib/dns/db.c:807:10
    #2 diff_apply lib/dns/diff.c:377:14
    #3 dns_diff_apply lib/dns/diff.c:458:10
    #4 do_one_tuple lib/dns/zone.c:4103:11
    #5 update_one_rr lib/dns/zone.c:4132:10
    #6 keyfetch_done lib/dns/zone.c:9835:4
    #7 dispatch lib/isc/task.c:1157:7
    #8 run lib/isc/task.c:1331:2

    Previous write of size 4 at 0x000000000001 by thread T2 (mutexes: write M2):
    #0 addrdataset lib/dns/rbtdb.c:6869:21
    #1 dns_db_addrdataset lib/dns/db.c:783:10
    #2 addoptout lib/dns/ncache.c:264:10
    #3 dns_ncache_add lib/dns/ncache.c:101:10
    #4 ncache_adderesult lib/dns/resolver.c:5989:12
    #5 ncache_message lib/dns/resolver.c:6165:11
    #6 resquery_response lib/dns/resolver.c:8691:12
    #7 dispatch lib/isc/task.c:1157:7
    #8 run lib/isc/task.c:1331:2

lib/dns/rbtdb.c

index 3a60bcf811db59c983100316f4c7b873a6595f5d..c60117c5eeb6e390337017da97196ae76a8d08b8 100644 (file)
@@ -1041,6 +1041,18 @@ hexdump(const char *desc, unsigned char *data, size_t size) {
 #define DNS_RDATASET_COUNT 0
 #endif /* DNS_RDATASET_FIXED */
 
+ISC_NO_SANITIZE_THREAD static ISC_NO_SANITIZE_INLINE unsigned int
+get_init_count(void) {
+       unsigned int value = DNS_RBTDB_INC(init_count);
+       return (value);
+}
+
+ISC_NO_SANITIZE_THREAD static ISC_NO_SANITIZE_INLINE unsigned int
+get_header_count(rdatasetheader_t *header) {
+       unsigned int value = DNS_RBTDB_INC(header->count);
+       return (value);
+}
+
 /*
  * DB Routines
  */
@@ -3347,7 +3359,7 @@ bind_rdataset(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node, rdatasetheader_t *header,
        rdataset->private2 = node;
        raw = (unsigned char *)header + sizeof(*header);
        rdataset->private3 = raw;
-       rdataset->count = DNS_RBTDB_INC(header->count);
+       rdataset->count = get_header_count(header);
        if (rdataset->count == UINT32_MAX)
                rdataset->count = 0;
 
@@ -6865,7 +6877,7 @@ addrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
                newheader->attributes |= RDATASET_ATTR_ZEROTTL;
        newheader->noqname = NULL;
        newheader->closest = NULL;
-       newheader->count = DNS_RBTDB_INC(init_count);
+       newheader->count = get_init_count();
        newheader->trust = rdataset->trust;
        newheader->additional_auth = NULL;
        newheader->additional_glue = NULL;
@@ -7061,7 +7073,7 @@ subtractrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
        newheader->trust = 0;
        newheader->noqname = NULL;
        newheader->closest = NULL;
-       newheader->count = DNS_RBTDB_INC(init_count);
+       newheader->count = get_init_count();
        newheader->additional_auth = NULL;
        newheader->additional_glue = NULL;
        newheader->last_used = 0;
@@ -7507,7 +7519,7 @@ loading_addrdataset(void *arg, dns_name_t *name, dns_rdataset_t *rdataset) {
        newheader->serial = 1;
        newheader->noqname = NULL;
        newheader->closest = NULL;
-       newheader->count = DNS_RBTDB_INC(init_count);
+       newheader->count = get_init_count();
        newheader->additional_auth = NULL;
        newheader->additional_glue = NULL;
        newheader->last_used = 0;