]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Lock 'responses' before reading it
authorMark Andrews <marka@isc.org>
Thu, 20 Aug 2020 00:21:50 +0000 (10:21 +1000)
committerMark Andrews <marka@isc.org>
Wed, 2 Sep 2020 03:07:03 +0000 (03:07 +0000)
WARNING: ThreadSanitizer: data race
  Read of size 4 at 0x000000000001 by main thread:
    #0 dispatch_getnext lib/dns/tests/dispatch_test.c:327
    #1 <null> <null>
    #2 __libc_start_main ../csu/libc-start.c:308

  Previous write of size 4 at 0x000000000001 by thread T1 (mutexes: write M1):
    #0 response lib/dns/tests/dispatch_test.c:234
    #1 dispatch lib/isc/task.c:1157
    #2 run lib/isc/task.c:1331
    #3 <null> <null>

  Location is global 'responses' of size 4 at 0x000000000001

  Mutex M1 (0x000000000009) created at:
    #0 pthread_mutex_init <null>
    #1 isc__mutex_init lib/isc/pthreads/mutex.c:287
    #2 dispatch_getnext lib/dns/tests/dispatch_test.c:273
    #3 <null> <null>
    #4 __libc_start_main ../csu/libc-start.c:308

  Thread T1 (running) created by main thread at:
    #0 pthread_create <null>
    #1 isc_thread_create lib/isc/pthreads/thread.c:60
    #2 isc__taskmgr_create lib/isc/task.c:1468
    #3 isc_taskmgr_create lib/isc/task.c:2109
    #4 create_managers lib/dns/tests/dnstest.c:118
    #5 dns_test_begin lib/dns/tests/dnstest.c:192
    #6 _setup lib/dns/tests/dispatch_test.c:53
    #7 <null> <null>
    #8 __libc_start_main ../csu/libc-start.c:308

SUMMARY: ThreadSanitizer: data race lib/dns/tests/dispatch_test.c:327 in dispatch_getnext

lib/dns/tests/dispatch_test.c

index ddc8bf16216c03ae82d9d8e893de84d22eac5d5e..91628f8f57776886aa058bf4aa2d92f9b47e1414 100644 (file)
@@ -324,7 +324,9 @@ dispatch_getnext(void **state) {
        result = isc_app_run();
        assert_int_equal(result, ISC_R_SUCCESS);
 
+       LOCK(&lock);
        assert_int_equal(responses, 2);
+       UNLOCK(&lock);
 
        /*
         * Shutdown nameserver.