Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

TSAN Detected Data Race: Fix or Note as False Positive #71

Closed
sherry-yuan opened this issue Feb 4, 2022 · 1 comment · Fixed by #74 or #89
Closed

TSAN Detected Data Race: Fix or Note as False Positive #71

sherry-yuan opened this issue Feb 4, 2022 · 1 comment · Fixed by #74 or #89
Assignees
Labels
bug Something isn't working
Milestone

Comments

@sherry-yuan
Copy link
Contributor

sherry-yuan commented Feb 4, 2022

The following are list of tsan detected data races

The following happened in threadsupport package (which we should note as false positive, given we don't want to change these third party libraries.

WARNING: ThreadSanitizer: data race (pid=714)
  Write of size 4 at 0x559b36f693d4 by thread T4 (mutexes: write M53):
    #0 test_thread(void*) ../lib/acl_threadsupport/test/acl_threadsupport_test.cpp:105 (acl_threadsupport_test+0xa490)

  Previous read of size 4 at 0x559b36f693d4 by main thread:
    #0 threadsupport_threads_Test::testBody() ../lib/acl_threadsupport/test/acl_threadsupport_test.cpp:128 (acl_threadsupport_test+0xaac8)
    #1 Utest::executePlatformSpecificTestBody() ../lib/CppUTest/src/UtestPlatformGcc.cpp:82 (acl_threadsupport_test+0x1d278)
    #2 Utest::runInThread() ../lib/CppUTest/src/Utest.cpp:99 (acl_threadsupport_test+0x1aa94)
    #3 threadsupport_threads_Test::runInThreadOnCopy() <null> (acl_threadsupport_test+0x108ef)
    #4 Utest::executePlatformSpecificRunInThreads() ../lib/CppUTest/src/UtestPlatformGcc.cpp:175 (acl_threadsupport_test+0x1d7aa)
    #5 Utest::run(TestResult&) ../lib/CppUTest/src/Utest.cpp:83 (acl_threadsupport_test+0x1a9e7)
    #6 Utest::runOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:69 (acl_threadsupport_test+0x1a8f6)
    #7 Utest::executePlatformSpecificRunOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/UtestPlatformGcc.cpp:100 (acl_threadsupport_test+0x1d4ba)
    #8 Utest::runOneTestWithPlugins(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:63 (acl_threadsupport_test+0x1a873)
    #9 TestRegistry::runAllTests(TestResult&) ../lib/CppUTest/src/TestRegistry.cpp:72 (acl_threadsupport_test+0x19c4d)
    #10 CommandLineTestRunner::runAllTests() ../lib/CppUTest/src/CommandLineTestRunner.cpp:105 (acl_threadsupport_test+0x133ac)
    #11 CommandLineTestRunner::runAllTestsMain() ../lib/CppUTest/src/CommandLineTestRunner.cpp:81 (acl_threadsupport_test+0x1354d)
    #12 CommandLineTestRunner::RunAllTests(int, char const**) ../lib/CppUTest/src/CommandLineTestRunner.cpp:63 (acl_threadsupport_test+0x1367d)
    #13 main ../lib/acl_threadsupport/test/acl_test.cpp:14 (acl_threadsupport_test+0x8c0b)

  Location is global 'threadtest_state' of size 4 at 0x559b36f693d4 (acl_threadsupport_test+0x00000002f3d4)

  Mutex M53 (0x559b36f693e0) created at:
    #0 pthread_mutex_init ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1220 (libtsan.so.0+0x4a616)
    #1 acl_mutex_init ../lib/acl_threadsupport/src/acl_threadsupport.c:97 (acl_threadsupport_test+0x120ec)
    #2 threadsupport_threads_Test::testBody() ../lib/acl_threadsupport/test/acl_threadsupport_test.cpp:115 (acl_threadsupport_test+0xa529)
    #3 Utest::executePlatformSpecificTestBody() ../lib/CppUTest/src/UtestPlatformGcc.cpp:82 (acl_threadsupport_test+0x1d278)
    #4 Utest::runInThread() ../lib/CppUTest/src/Utest.cpp:99 (acl_threadsupport_test+0x1aa94)
    #5 threadsupport_threads_Test::runInThreadOnCopy() <null> (acl_threadsupport_test+0x108ef)
    #6 Utest::executePlatformSpecificRunInThreads() ../lib/CppUTest/src/UtestPlatformGcc.cpp:175 (acl_threadsupport_test+0x1d7aa)
    #7 Utest::run(TestResult&) ../lib/CppUTest/src/Utest.cpp:83 (acl_threadsupport_test+0x1a9e7)
    #8 Utest::runOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:69 (acl_threadsupport_test+0x1a8f6)
    #9 Utest::executePlatformSpecificRunOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/UtestPlatformGcc.cpp:100 (acl_threadsupport_test+0x1d4ba)
    #10 Utest::runOneTestWithPlugins(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:63 (acl_threadsupport_test+0x1a873)
    #11 TestRegistry::runAllTests(TestResult&) ../lib/CppUTest/src/TestRegistry.cpp:72 (acl_threadsupport_test+0x19c4d)
    #12 CommandLineTestRunner::runAllTests() ../lib/CppUTest/src/CommandLineTestRunner.cpp:105 (acl_threadsupport_test+0x133ac)
    #13 CommandLineTestRunner::runAllTestsMain() ../lib/CppUTest/src/CommandLineTestRunner.cpp:81 (acl_threadsupport_test+0x1354d)
    #14 CommandLineTestRunner::RunAllTests(int, char const**) ../lib/CppUTest/src/CommandLineTestRunner.cpp:63 (acl_threadsupport_test+0x1367d)
    #15 main ../lib/acl_threadsupport/test/acl_test.cpp:14 (acl_threadsupport_test+0x8c0b)

  Thread T4 (tid=719, running) created by main thread at:
    #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:962 (libtsan.so.0+0x5ea79)
    #1 acl_thread_create ../lib/acl_threadsupport/src/acl_threadsupport.c:50 (acl_threadsupport_test+0x11ed9)
    #2 threadsupport_threads_Test::testBody() ../lib/acl_threadsupport/test/acl_threadsupport_test.cpp:121 (acl_threadsupport_test+0xa781)
    #3 Utest::executePlatformSpecificTestBody() ../lib/CppUTest/src/UtestPlatformGcc.cpp:82 (acl_threadsupport_test+0x1d278)
    #4 Utest::runInThread() ../lib/CppUTest/src/Utest.cpp:99 (acl_threadsupport_test+0x1aa94)
    #5 threadsupport_threads_Test::runInThreadOnCopy() <null> (acl_threadsupport_test+0x108ef)
    #6 Utest::executePlatformSpecificRunInThreads() ../lib/CppUTest/src/UtestPlatformGcc.cpp:175 (acl_threadsupport_test+0x1d7aa)
    #7 Utest::run(TestResult&) ../lib/CppUTest/src/Utest.cpp:83 (acl_threadsupport_test+0x1a9e7)
    #8 Utest::runOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:69 (acl_threadsupport_test+0x1a8f6)
    #9 Utest::executePlatformSpecificRunOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/UtestPlatformGcc.cpp:100 (acl_threadsupport_test+0x1d4ba)
    #10 Utest::runOneTestWithPlugins(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:63 (acl_threadsupport_test+0x1a873)
    #11 TestRegistry::runAllTests(TestResult&) ../lib/CppUTest/src/TestRegistry.cpp:72 (acl_threadsupport_test+0x19c4d)
    #12 CommandLineTestRunner::runAllTests() ../lib/CppUTest/src/CommandLineTestRunner.cpp:105 (acl_threadsupport_test+0x133ac)
    #13 CommandLineTestRunner::runAllTestsMain() ../lib/CppUTest/src/CommandLineTestRunner.cpp:81 (acl_threadsupport_test+0x1354d)
    #14 CommandLineTestRunner::RunAllTests(int, char const**) ../lib/CppUTest/src/CommandLineTestRunner.cpp:63 (acl_threadsupport_test+0x1367d)
    #15 main ../lib/acl_threadsupport/test/acl_test.cpp:14 (acl_threadsupport_test+0x8c0b)

SUMMARY: ThreadSanitizer: data race ../lib/acl_threadsupport/test/acl_threadsupport_test.cpp:105 in test_thread(void*)

The following are found in our source code which is what we should care about

WARNING: ThreadSanitizer: heap-use-after-free (pid=737)
  Read of size 4 at 0x7b3c000003d4 by main thread:
    #0 acl_ref_count<_cl_command_queue*> ../include/acl_util.h:433 (acl_test+0x1263a8)
    #1 acl_command_queue_after_context_release_Test::testBody() ../test/acl_command_queue_test.cpp:677 (acl_test+0x1263a8)
    #2 Utest::executePlatformSpecificTestBody() ../lib/CppUTest/src/UtestPlatformGcc.cpp:82 (acl_test+0x54e3b4)
    #3 Utest::runInThread() ../lib/CppUTest/src/Utest.cpp:99 (acl_test+0x54bbd0)
    #4 acl_command_queue_after_context_release_Test::runInThreadOnCopy() ../test/acl_command_queue_test.cpp:622 (acl_test+0x13c1c0)
    #5 Utest::executePlatformSpecificRunInThreads() ../lib/CppUTest/src/UtestPlatformGcc.cpp:175 (acl_test+0x54e8e6)
    #6 Utest::run(TestResult&) ../lib/CppUTest/src/Utest.cpp:83 (acl_test+0x54bb23)
    #7 Utest::runOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:69 (acl_test+0x54ba32)
    #8 Utest::executePlatformSpecificRunOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/UtestPlatformGcc.cpp:100 (acl_test+0x54e5f6)
    #9 Utest::runOneTestWithPlugins(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:63 (acl_test+0x54b9af)
    #10 TestRegistry::runAllTests(TestResult&) ../lib/CppUTest/src/TestRegistry.cpp:72 (acl_test+0x54ad89)
    #11 CommandLineTestRunner::runAllTests() ../lib/CppUTest/src/CommandLineTestRunner.cpp:105 (acl_test+0x5444e8)
    #12 CommandLineTestRunner::runAllTestsMain() ../lib/CppUTest/src/CommandLineTestRunner.cpp:81 (acl_test+0x544689)
    #13 CommandLineTestRunner::RunAllTests(int, char const**) ../lib/CppUTest/src/CommandLineTestRunner.cpp:63 (acl_test+0x5447b9)
    #14 main ../test/acl_test.cpp:90 (acl_test+0x4b3f45)

  Previous write of size 8 at 0x7b3c000003d0 by main thread (mutexes: write M44):
    #0 operator delete(void*) ../../../../src/libsanitizer/tsan/tsan_new_delete.cpp:126 (libtsan.so.0+0x8b2c8)
    #1 acl_delete<_cl_command_queue> ../include/acl_support.h:31 (acl_test+0x49040)
    #2 acl_free_cl_command_queue ../src/acl_command_queue.cpp:99 (acl_test+0x49040)
    #3 acl_delete_command_queue ../src/acl_command_queue.cpp:1005 (acl_test+0x49316)
    #4 clReleaseCommandQueueIntelFPGA ../src/acl_command_queue.cpp:288 (acl_test+0x4a755)
    #5 clReleaseCommandQueue ../src/acl_command_queue.cpp:297 (acl_test+0x4a7ad)
    #6 acl_command_queue_after_context_release_Test::testBody() ../test/acl_command_queue_test.cpp:675 (acl_test+0x126192)
    #7 Utest::executePlatformSpecificTestBody() ../lib/CppUTest/src/UtestPlatformGcc.cpp:82 (acl_test+0x54e3b4)
    #8 Utest::runInThread() ../lib/CppUTest/src/Utest.cpp:99 (acl_test+0x54bbd0)
    #9 acl_command_queue_after_context_release_Test::runInThreadOnCopy() ../test/acl_command_queue_test.cpp:622 (acl_test+0x13c1c0)
    #10 Utest::executePlatformSpecificRunInThreads() ../lib/CppUTest/src/UtestPlatformGcc.cpp:175 (acl_test+0x54e8e6)
    #11 Utest::run(TestResult&) ../lib/CppUTest/src/Utest.cpp:83 (acl_test+0x54bb23)
    #12 Utest::runOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:69 (acl_test+0x54ba32)
    #13 Utest::executePlatformSpecificRunOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/UtestPlatformGcc.cpp:100 (acl_test+0x54e5f6)
    #14 Utest::runOneTestWithPlugins(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:63 (acl_test+0x54b9af)
    #15 TestRegistry::runAllTests(TestResult&) ../lib/CppUTest/src/TestRegistry.cpp:72 (acl_test+0x54ad89)
    #16 CommandLineTestRunner::runAllTests() ../lib/CppUTest/src/CommandLineTestRunner.cpp:105 (acl_test+0x5444e8)
    #17 CommandLineTestRunner::runAllTestsMain() ../lib/CppUTest/src/CommandLineTestRunner.cpp:81 (acl_test+0x544689)
    #18 CommandLineTestRunner::RunAllTests(int, char const**) ../lib/CppUTest/src/CommandLineTestRunner.cpp:63 (acl_test+0x5447b9)
    #19 main ../test/acl_test.cpp:90 (acl_test+0x4b3f45)

  Mutex M44 (0x55817c8c2100) created at:
    #0 pthread_mutex_init ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1220 (libtsan.so.0+0x4a616)
    #1 acl_init_condvar ../lib/acl_threadsupport/src/acl_threadsupport.c:330 (acl_test+0x54382e)
    #2 l_global_lock_init ../src/acl_thread.cpp:102 (acl_test+0x102eda)
    #3 __libc_csu_init <null> (acl_test+0x556acc)

SUMMARY: ThreadSanitizer: heap-use-after-free ../include/acl_util.h:433 in acl_ref_count<_cl_command_queue*>
==================
==================
WARNING: ThreadSanitizer: heap-use-after-free (pid=737)
  Read of size 4 at 0x7b3c000002e4 by main thread:
    #0 acl_ref_count<_cl_command_queue*> ../include/acl_util.h:433 (acl_test+0x1264c3)
    #1 acl_command_queue_after_context_release_Test::testBody() ../test/acl_command_queue_test.cpp:678 (acl_test+0x1264c3)
    #2 Utest::executePlatformSpecificTestBody() ../lib/CppUTest/src/UtestPlatformGcc.cpp:82 (acl_test+0x54e3b4)
    #3 Utest::runInThread() ../lib/CppUTest/src/Utest.cpp:99 (acl_test+0x54bbd0)
    #4 acl_command_queue_after_context_release_Test::runInThreadOnCopy() ../test/acl_command_queue_test.cpp:622 (acl_test+0x13c1c0)
    #5 Utest::executePlatformSpecificRunInThreads() ../lib/CppUTest/src/UtestPlatformGcc.cpp:175 (acl_test+0x54e8e6)
    #6 Utest::run(TestResult&) ../lib/CppUTest/src/Utest.cpp:83 (acl_test+0x54bb23)
    #7 Utest::runOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:69 (acl_test+0x54ba32)
    #8 Utest::executePlatformSpecificRunOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/UtestPlatformGcc.cpp:100 (acl_test+0x54e5f6)
    #9 Utest::runOneTestWithPlugins(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:63 (acl_test+0x54b9af)
    #10 TestRegistry::runAllTests(TestResult&) ../lib/CppUTest/src/TestRegistry.cpp:72 (acl_test+0x54ad89)
    #11 CommandLineTestRunner::runAllTests() ../lib/CppUTest/src/CommandLineTestRunner.cpp:105 (acl_test+0x5444e8)
    #12 CommandLineTestRunner::runAllTestsMain() ../lib/CppUTest/src/CommandLineTestRunner.cpp:81 (acl_test+0x544689)
    #13 CommandLineTestRunner::RunAllTests(int, char const**) ../lib/CppUTest/src/CommandLineTestRunner.cpp:63 (acl_test+0x5447b9)
    #14 main ../test/acl_test.cpp:90 (acl_test+0x4b3f45)

  Previous write of size 8 at 0x7b3c000002e0 by main thread (mutexes: write M44):
    #0 operator delete(void*) ../../../../src/libsanitizer/tsan/tsan_new_delete.cpp:126 (libtsan.so.0+0x8b2c8)
    #1 acl_delete<_cl_command_queue> ../include/acl_support.h:31 (acl_test+0x49040)
    #2 acl_free_cl_command_queue ../src/acl_command_queue.cpp:99 (acl_test+0x49040)
    #3 acl_delete_command_queue ../src/acl_command_queue.cpp:1005 (acl_test+0x49316)
    #4 clReleaseCommandQueueIntelFPGA ../src/acl_command_queue.cpp:288 (acl_test+0x4a755)
    #5 clReleaseCommandQueue ../src/acl_command_queue.cpp:297 (acl_test+0x4a7ad)
    #6 acl_command_queue_after_context_release_Test::testBody() ../test/acl_command_queue_test.cpp:676 (acl_test+0x12629d)
    #7 Utest::executePlatformSpecificTestBody() ../lib/CppUTest/src/UtestPlatformGcc.cpp:82 (acl_test+0x54e3b4)
    #8 Utest::runInThread() ../lib/CppUTest/src/Utest.cpp:99 (acl_test+0x54bbd0)
    #9 acl_command_queue_after_context_release_Test::runInThreadOnCopy() ../test/acl_command_queue_test.cpp:622 (acl_test+0x13c1c0)
    #10 Utest::executePlatformSpecificRunInThreads() ../lib/CppUTest/src/UtestPlatformGcc.cpp:175 (acl_test+0x54e8e6)
    #11 Utest::run(TestResult&) ../lib/CppUTest/src/Utest.cpp:83 (acl_test+0x54bb23)
    #12 Utest::runOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:69 (acl_test+0x54ba32)
    #13 Utest::executePlatformSpecificRunOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/UtestPlatformGcc.cpp:100 (acl_test+0x54e5f6)
    #14 Utest::runOneTestWithPlugins(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:63 (acl_test+0x54b9af)
    #15 TestRegistry::runAllTests(TestResult&) ../lib/CppUTest/src/TestRegistry.cpp:72 (acl_test+0x54ad89)
    #16 CommandLineTestRunner::runAllTests() ../lib/CppUTest/src/CommandLineTestRunner.cpp:105 (acl_test+0x5444e8)
    #17 CommandLineTestRunner::runAllTestsMain() ../lib/CppUTest/src/CommandLineTestRunner.cpp:81 (acl_test+0x544689)
    #18 CommandLineTestRunner::RunAllTests(int, char const**) ../lib/CppUTest/src/CommandLineTestRunner.cpp:63 (acl_test+0x5447b9)
    #19 main ../test/acl_test.cpp:90 (acl_test+0x4b3f45)

  Mutex M44 (0x55817c8c2100) created at:
    #0 pthread_mutex_init ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1220 (libtsan.so.0+0x4a616)
    #1 acl_init_condvar ../lib/acl_threadsupport/src/acl_threadsupport.c:330 (acl_test+0x54382e)
    #2 l_global_lock_init ../src/acl_thread.cpp:102 (acl_test+0x102eda)
    #3 __libc_csu_init <null> (acl_test+0x556acc)

SUMMARY: ThreadSanitizer: heap-use-after-free ../include/acl_util.h:433 in acl_ref_count<_cl_command_queue*>
==================
==================
WARNING: ThreadSanitizer: heap-use-after-free (pid=737)
  Read of size 8 at 0x7b3c000003c8 by main thread (mutexes: write M44):
    #0 int acl_is_valid_ptr<_cl_command_queue*>(_cl_command_queue* const&) ../include/acl_util.h:417 (acl_test+0x4a45d)
    #1 acl_command_queue_is_valid(_cl_command_queue*) ../src/acl_command_queue.cpp:553 (acl_test+0x4a45d)
    #2 acl_command_queue_after_context_release_Test::testBody() ../test/acl_command_queue_test.cpp:680 (acl_test+0x126600)
    #3 Utest::executePlatformSpecificTestBody() ../lib/CppUTest/src/UtestPlatformGcc.cpp:82 (acl_test+0x54e3b4)
    #4 Utest::runInThread() ../lib/CppUTest/src/Utest.cpp:99 (acl_test+0x54bbd0)
    #5 acl_command_queue_after_context_release_Test::runInThreadOnCopy() ../test/acl_command_queue_test.cpp:622 (acl_test+0x13c1c0)
    #6 Utest::executePlatformSpecificRunInThreads() ../lib/CppUTest/src/UtestPlatformGcc.cpp:175 (acl_test+0x54e8e6)
    #7 Utest::run(TestResult&) ../lib/CppUTest/src/Utest.cpp:83 (acl_test+0x54bb23)
    #8 Utest::runOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:69 (acl_test+0x54ba32)
    #9 Utest::executePlatformSpecificRunOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/UtestPlatformGcc.cpp:100 (acl_test+0x54e5f6)
    #10 Utest::runOneTestWithPlugins(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:63 (acl_test+0x54b9af)
    #11 TestRegistry::runAllTests(TestResult&) ../lib/CppUTest/src/TestRegistry.cpp:72 (acl_test+0x54ad89)
    #12 CommandLineTestRunner::runAllTests() ../lib/CppUTest/src/CommandLineTestRunner.cpp:105 (acl_test+0x5444e8)
    #13 CommandLineTestRunner::runAllTestsMain() ../lib/CppUTest/src/CommandLineTestRunner.cpp:81 (acl_test+0x544689)
    #14 CommandLineTestRunner::RunAllTests(int, char const**) ../lib/CppUTest/src/CommandLineTestRunner.cpp:63 (acl_test+0x5447b9)
    #15 main ../test/acl_test.cpp:90 (acl_test+0x4b3f45)

  Previous write of size 8 at 0x7b3c000003c8 by main thread (mutexes: write M44):
    #0 operator delete(void*) ../../../../src/libsanitizer/tsan/tsan_new_delete.cpp:126 (libtsan.so.0+0x8b2c8)
    #1 acl_delete<_cl_command_queue> ../include/acl_support.h:31 (acl_test+0x49040)
    #2 acl_free_cl_command_queue ../src/acl_command_queue.cpp:99 (acl_test+0x49040)
    #3 acl_delete_command_queue ../src/acl_command_queue.cpp:1005 (acl_test+0x49316)
    #4 clReleaseCommandQueueIntelFPGA ../src/acl_command_queue.cpp:288 (acl_test+0x4a755)
    #5 clReleaseCommandQueue ../src/acl_command_queue.cpp:297 (acl_test+0x4a7ad)
    #6 acl_command_queue_after_context_release_Test::testBody() ../test/acl_command_queue_test.cpp:675 (acl_test+0x126192)
    #7 Utest::executePlatformSpecificTestBody() ../lib/CppUTest/src/UtestPlatformGcc.cpp:82 (acl_test+0x54e3b4)
    #8 Utest::runInThread() ../lib/CppUTest/src/Utest.cpp:99 (acl_test+0x54bbd0)
    #9 acl_command_queue_after_context_release_Test::runInThreadOnCopy() ../test/acl_command_queue_test.cpp:622 (acl_test+0x13c1c0)
    #10 Utest::executePlatformSpecificRunInThreads() ../lib/CppUTest/src/UtestPlatformGcc.cpp:175 (acl_test+0x54e8e6)
    #11 Utest::run(TestResult&) ../lib/CppUTest/src/Utest.cpp:83 (acl_test+0x54bb23)
    #12 Utest::runOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:69 (acl_test+0x54ba32)
    #13 Utest::executePlatformSpecificRunOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/UtestPlatformGcc.cpp:100 (acl_test+0x54e5f6)
    #14 Utest::runOneTestWithPlugins(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:63 (acl_test+0x54b9af)
    #15 TestRegistry::runAllTests(TestResult&) ../lib/CppUTest/src/TestRegistry.cpp:72 (acl_test+0x54ad89)
    #16 CommandLineTestRunner::runAllTests() ../lib/CppUTest/src/CommandLineTestRunner.cpp:105 (acl_test+0x5444e8)
    #17 CommandLineTestRunner::runAllTestsMain() ../lib/CppUTest/src/CommandLineTestRunner.cpp:81 (acl_test+0x544689)
    #18 CommandLineTestRunner::RunAllTests(int, char const**) ../lib/CppUTest/src/CommandLineTestRunner.cpp:63 (acl_test+0x5447b9)
    #19 main ../test/acl_test.cpp:90 (acl_test+0x4b3f45)

  Mutex M44 (0x55817c8c2100) created at:
    #0 pthread_mutex_init ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1220 (libtsan.so.0+0x4a616)
    #1 acl_init_condvar ../lib/acl_threadsupport/src/acl_threadsupport.c:330 (acl_test+0x54382e)
    #2 l_global_lock_init ../src/acl_thread.cpp:102 (acl_test+0x102eda)
    #3 __libc_csu_init <null> (acl_test+0x556acc)

SUMMARY: ThreadSanitizer: heap-use-after-free ../include/acl_util.h:417 in int acl_is_valid_ptr<_cl_command_queue*>(_cl_command_queue* const&)
==================
==================
WARNING: ThreadSanitizer: heap-use-after-free (pid=737)
  Read of size 8 at 0x7b3c000002d8 by main thread (mutexes: write M44):
    #0 int acl_is_valid_ptr<_cl_command_queue*>(_cl_command_queue* const&) ../include/acl_util.h:417 (acl_test+0x4a45d)
    #1 acl_command_queue_is_valid(_cl_command_queue*) ../src/acl_command_queue.cpp:553 (acl_test+0x4a45d)
    #2 acl_command_queue_after_context_release_Test::testBody() ../test/acl_command_queue_test.cpp:681 (acl_test+0x12666e)
    #3 Utest::executePlatformSpecificTestBody() ../lib/CppUTest/src/UtestPlatformGcc.cpp:82 (acl_test+0x54e3b4)
    #4 Utest::runInThread() ../lib/CppUTest/src/Utest.cpp:99 (acl_test+0x54bbd0)
    #5 acl_command_queue_after_context_release_Test::runInThreadOnCopy() ../test/acl_command_queue_test.cpp:622 (acl_test+0x13c1c0)
    #6 Utest::executePlatformSpecificRunInThreads() ../lib/CppUTest/src/UtestPlatformGcc.cpp:175 (acl_test+0x54e8e6)
    #7 Utest::run(TestResult&) ../lib/CppUTest/src/Utest.cpp:83 (acl_test+0x54bb23)
    #8 Utest::runOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:69 (acl_test+0x54ba32)
    #9 Utest::executePlatformSpecificRunOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/UtestPlatformGcc.cpp:100 (acl_test+0x54e5f6)
    #10 Utest::runOneTestWithPlugins(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:63 (acl_test+0x54b9af)
    #11 TestRegistry::runAllTests(TestResult&) ../lib/CppUTest/src/TestRegistry.cpp:72 (acl_test+0x54ad89)
    #12 CommandLineTestRunner::runAllTests() ../lib/CppUTest/src/CommandLineTestRunner.cpp:105 (acl_test+0x5444e8)
    #13 CommandLineTestRunner::runAllTestsMain() ../lib/CppUTest/src/CommandLineTestRunner.cpp:81 (acl_test+0x544689)
    #14 CommandLineTestRunner::RunAllTests(int, char const**) ../lib/CppUTest/src/CommandLineTestRunner.cpp:63 (acl_test+0x5447b9)
    #15 main ../test/acl_test.cpp:90 (acl_test+0x4b3f45)

  Previous write of size 8 at 0x7b3c000002d8 by main thread (mutexes: write M44):
    #0 operator delete(void*) ../../../../src/libsanitizer/tsan/tsan_new_delete.cpp:126 (libtsan.so.0+0x8b2c8)
    #1 acl_delete<_cl_command_queue> ../include/acl_support.h:31 (acl_test+0x49040)
    #2 acl_free_cl_command_queue ../src/acl_command_queue.cpp:99 (acl_test+0x49040)
    #3 acl_delete_command_queue ../src/acl_command_queue.cpp:1005 (acl_test+0x49316)
    #4 clReleaseCommandQueueIntelFPGA ../src/acl_command_queue.cpp:288 (acl_test+0x4a755)
    #5 clReleaseCommandQueue ../src/acl_command_queue.cpp:297 (acl_test+0x4a7ad)
    #6 acl_command_queue_after_context_release_Test::testBody() ../test/acl_command_queue_test.cpp:676 (acl_test+0x12629d)
    #7 Utest::executePlatformSpecificTestBody() ../lib/CppUTest/src/UtestPlatformGcc.cpp:82 (acl_test+0x54e3b4)
    #8 Utest::runInThread() ../lib/CppUTest/src/Utest.cpp:99 (acl_test+0x54bbd0)
    #9 acl_command_queue_after_context_release_Test::runInThreadOnCopy() ../test/acl_command_queue_test.cpp:622 (acl_test+0x13c1c0)
    #10 Utest::executePlatformSpecificRunInThreads() ../lib/CppUTest/src/UtestPlatformGcc.cpp:175 (acl_test+0x54e8e6)
    #11 Utest::run(TestResult&) ../lib/CppUTest/src/Utest.cpp:83 (acl_test+0x54bb23)
    #12 Utest::runOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:69 (acl_test+0x54ba32)
    #13 Utest::executePlatformSpecificRunOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/UtestPlatformGcc.cpp:100 (acl_test+0x54e5f6)
    #14 Utest::runOneTestWithPlugins(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:63 (acl_test+0x54b9af)
    #15 TestRegistry::runAllTests(TestResult&) ../lib/CppUTest/src/TestRegistry.cpp:72 (acl_test+0x54ad89)
    #16 CommandLineTestRunner::runAllTests() ../lib/CppUTest/src/CommandLineTestRunner.cpp:105 (acl_test+0x5444e8)
    #17 CommandLineTestRunner::runAllTestsMain() ../lib/CppUTest/src/CommandLineTestRunner.cpp:81 (acl_test+0x544689)
    #18 CommandLineTestRunner::RunAllTests(int, char const**) ../lib/CppUTest/src/CommandLineTestRunner.cpp:63 (acl_test+0x5447b9)
    #19 main ../test/acl_test.cpp:90 (acl_test+0x4b3f45)

  Mutex M44 (0x55817c8c2100) created at:
    #0 pthread_mutex_init ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1220 (libtsan.so.0+0x4a616)
    #1 acl_init_condvar ../lib/acl_threadsupport/src/acl_threadsupport.c:330 (acl_test+0x54382e)
    #2 l_global_lock_init ../src/acl_thread.cpp:102 (acl_test+0x102eda)
    #3 __libc_csu_init <null> (acl_test+0x556acc)

SUMMARY: ThreadSanitizer: heap-use-after-free ../include/acl_util.h:417 in int acl_is_valid_ptr<_cl_command_queue*>(_cl_command_queue* const&)
==================
sherry-yuan added a commit to sherry-yuan/fpga-runtime-for-opencl that referenced this issue Feb 4, 2022
------------------------------------------------------

As found in intel#71, tsan reported several issues in the acl_test

Currently when release command queue are called (which frees the memory) subsequent still checks the values at the same address which cause tsan to report heap-use-after-free.

The test after_context_release are moved upward to be the first test because ctest execute the test in reverse order of how they appear in the cpp file. Given after_context_release will release the command queue, they should be run last, i.e place at the top in the test.cpp file
@sherry-yuan sherry-yuan self-assigned this Feb 7, 2022
@sherry-yuan sherry-yuan added the bug Something isn't working label Feb 7, 2022
@sherry-yuan sherry-yuan added this to the 2022.3 milestone Feb 7, 2022
sherry-yuan added a commit to sherry-yuan/fpga-runtime-for-opencl that referenced this issue Feb 7, 2022
------------------------------------------------------

As found in intel#71, tsan reported several issues in the acl_test

Currently when release command queue are called (which frees the memory) subsequent still checks the values at the same address which cause tsan to report heap-use-after-free.

The test after_context_release are moved upward to be the first test because ctest execute the test in reverse order of how they appear in the cpp file. Given after_context_release will release the command queue, they should be run last, i.e place at the top in the test.cpp file
sherry-yuan added a commit to sherry-yuan/fpga-runtime-for-opencl that referenced this issue Feb 7, 2022
------------------------------------------------------

As found in intel#71, tsan reported several issues in the acl_test

Currently when release command queue are called (which frees the memory) subsequent still checks the values at the same address which cause tsan to report heap-use-after-free.
sherry-yuan added a commit to sherry-yuan/fpga-runtime-for-opencl that referenced this issue Feb 8, 2022
------------------------------------------------------

As found in intel#71, tsan reported several issues in the acl_test

Currently when release command queue are called (which frees the memory) subsequent still checks the values at the same address which cause tsan to report heap-use-after-free.
sherry-yuan added a commit to sherry-yuan/fpga-runtime-for-opencl that referenced this issue Feb 8, 2022
----------------------------------------------

Thread sanitizer (TSAN) is a tool that detect data races, deadlocks  between threads. (it also sometimes report heap-use-after-free in same thread check intel#71 for issues reported in current repo)

For more information, checkout https://clang.llvm.org/docs/ThreadSanitizer.html
pcolberg pushed a commit to sherry-yuan/fpga-runtime-for-opencl that referenced this issue Feb 17, 2022
Thread sanitizer (TSAN) is a tool that detect data races and deadlocks between threads. (It also sometimes report heap-use-after-free in same thread check intel#71 for issues reported in current repo)
pcolberg pushed a commit that referenced this issue Feb 17, 2022
Thread sanitizer (TSAN) is a tool that detect data races and deadlocks between threads. (It also sometimes report heap-use-after-free in same thread check #71 for issues reported in current repo)
pcolberg pushed a commit to sherry-yuan/fpga-runtime-for-opencl that referenced this issue Feb 17, 2022
As found in intel#71, tsan reported several issues in the acl_test

Currently when release command queue are called (which frees the memory) subsequent still checks the values at the same address which cause tsan to report heap-use-after-free.

6: TEST(acl_command_queue, after_context_release)==================
6: WARNING: ThreadSanitizer: heap-use-after-free (pid=2499)
6:   Read of size 4 at 0x7b3c000004c4 by main thread:
6:     #0 acl_ref_count<_cl_command_queue*> ../include/acl_util.h:433 (acl_test+0x000000524583)
6:     intel#1 acl_command_queue_after_context_release_Test::testBody() ../test/acl_command_queue_test.cpp:677 (acl_test+0x000000524583)
6:     intel#2 Utest::executePlatformSpecificTestBody() ../lib/CppUTest/src/UtestPlatformGcc.cpp:82 (acl_test+0x0000009320a0)
6:     intel#3 Utest::runInThread() ../lib/CppUTest/src/Utest.cpp:99 (acl_test+0x00000092fe78)
6:     intel#4 acl_command_queue_after_context_release_Test::runInThreadOnCopy() ../test/acl_command_queue_test.cpp:622 (acl_test+0x000000538b4c)
6:     intel#5 Utest::executePlatformSpecificRunInThreads() ../lib/CppUTest/src/UtestPlatformGcc.cpp:175 (acl_test+0x000000932582)
6:     intel#6 Utest::run(TestResult&) ../lib/CppUTest/src/Utest.cpp:83 (acl_test+0x00000092fdd4)
6:     intel#7 Utest::runOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:69 (acl_test+0x00000092fcf2)
6:     intel#8 Utest::executePlatformSpecificRunOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/UtestPlatformGcc.cpp:100 (acl_test+0x0000009322be)
6:     intel#9 Utest::runOneTestWithPlugins(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:63 (acl_test+0x00000092fc77)
6:     intel#10 TestRegistry::runAllTests(TestResult&) ../lib/CppUTest/src/TestRegistry.cpp:72 (acl_test+0x00000092f124)
6:     intel#11 CommandLineTestRunner::runAllTests() ../lib/CppUTest/src/CommandLineTestRunner.cpp:105 (acl_test+0x00000092947d)
6:     intel#12 CommandLineTestRunner::runAllTestsMain() ../lib/CppUTest/src/CommandLineTestRunner.cpp:81 (acl_test+0x0000009295bd)
6:     intel#13 CommandLineTestRunner::RunAllTests(int, char const**) ../lib/CppUTest/src/CommandLineTestRunner.cpp:63 (acl_test+0x0000009296e4)
6:     intel#14 main ../test/acl_test.cpp:90 (acl_test+0x00000090d2d4)
6:
6:   Previous write of size 8 at 0x7b3c000004c0 by main thread (mutexes: write M41):
6:     #0 operator delete(void*) /nfs/site/disks/swip_pr_1/kbrunham/p4root/depot/devenv/tools/gcc/7.4.0/work/src/libsanitizer/tsan/tsan_new_delete.cc:71 (libtsan.so.0+0x00000006af04)
6:     intel#1 acl_delete<_cl_command_queue> ../include/acl_support.h:31 (acl_test+0x00000041118c)
6:     intel#2 acl_free_cl_command_queue ../src/acl_command_queue.cpp:99 (acl_test+0x00000041118c)
6:     intel#3 acl_delete_command_queue ../src/acl_command_queue.cpp:1005 (acl_test+0x000000411461)
6:     intel#4 clReleaseCommandQueueIntelFPGA ../src/acl_command_queue.cpp:288 (acl_test+0x000000413a1e)
6:     intel#5 clReleaseCommandQueue ../src/acl_command_queue.cpp:297 (acl_test+0x000000413a6e)
6:     intel#6 acl_command_queue_after_context_release_Test::testBody() ../test/acl_command_queue_test.cpp:675 (acl_test+0x000000524379)
6:     intel#7 Utest::executePlatformSpecificTestBody() ../lib/CppUTest/src/UtestPlatformGcc.cpp:82 (acl_test+0x0000009320a0)
6:     intel#8 Utest::runInThread() ../lib/CppUTest/src/Utest.cpp:99 (acl_test+0x00000092fe78)
6:     intel#9 acl_command_queue_after_context_release_Test::runInThreadOnCopy() ../test/acl_command_queue_test.cpp:622 (acl_test+0x000000538b4c)
6:     intel#10 Utest::executePlatformSpecificRunInThreads() ../lib/CppUTest/src/UtestPlatformGcc.cpp:175 (acl_test+0x000000932582)
6:     intel#11 Utest::run(TestResult&) ../lib/CppUTest/src/Utest.cpp:83 (acl_test+0x00000092fdd4)
6:     intel#12 Utest::runOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:69 (acl_test+0x00000092fcf2)
6:     intel#13 Utest::executePlatformSpecificRunOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/UtestPlatformGcc.cpp:100 (acl_test+0x0000009322be)
6:     intel#14 Utest::runOneTestWithPlugins(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:63 (acl_test+0x00000092fc77)
6:     intel#15 TestRegistry::runAllTests(TestResult&) ../lib/CppUTest/src/TestRegistry.cpp:72 (acl_test+0x00000092f124)
6:     intel#16 CommandLineTestRunner::runAllTests() ../lib/CppUTest/src/CommandLineTestRunner.cpp:105 (acl_test+0x00000092947d)
6:     intel#17 CommandLineTestRunner::runAllTestsMain() ../lib/CppUTest/src/CommandLineTestRunner.cpp:81 (acl_test+0x0000009295bd)
6:     intel#18 CommandLineTestRunner::RunAllTests(int, char const**) ../lib/CppUTest/src/CommandLineTestRunner.cpp:63 (acl_test+0x0000009296e4)
6:     intel#19 main ../test/acl_test.cpp:90 (acl_test+0x00000090d2d4)
6:
6:   Mutex M41 (0x000004dfc600) created at:
6:     #0 pthread_mutex_init /nfs/site/disks/swip_pr_1/kbrunham/p4root/depot/devenv/tools/gcc/7.4.0/work/src/libsanitizer/tsan/tsan_interceptors.cc:1117 (libtsan.so.0+0x0000000291fe)
6:     intel#1 acl_init_condvar ../lib/acl_threadsupport/src/acl_threadsupport.c:330 (acl_test+0x000000928951)
6:     intel#2 l_global_lock_init ../src/acl_thread.cpp:102 (acl_test+0x0000004fe4eb)
6:     intel#3 __libc_csu_init /home/abuild/rpmbuild/BUILD/glibc-2.22/csu/elf-init.c:88 (acl_test+0x00000093a06c)
6:
6: SUMMARY: ThreadSanitizer: heap-use-after-free ../include/acl_util.h:433 in acl_ref_count<_cl_command_queue*>
6: ==================
6: ==================
6: WARNING: ThreadSanitizer: heap-use-after-free (pid=2499)
6:   Read of size 4 at 0x7b3c000003d4 by main thread:
6:     #0 acl_ref_count<_cl_command_queue*> ../include/acl_util.h:433 (acl_test+0x000000524691)
6:     intel#1 acl_command_queue_after_context_release_Test::testBody() ../test/acl_command_queue_test.cpp:678 (acl_test+0x000000524691)
6:     intel#2 Utest::executePlatformSpecificTestBody() ../lib/CppUTest/src/UtestPlatformGcc.cpp:82 (acl_test+0x0000009320a0)
6:     intel#3 Utest::runInThread() ../lib/CppUTest/src/Utest.cpp:99 (acl_test+0x00000092fe78)
6:     intel#4 acl_command_queue_after_context_release_Test::runInThreadOnCopy() ../test/acl_command_queue_test.cpp:622 (acl_test+0x000000538b4c)
6:     intel#5 Utest::executePlatformSpecificRunInThreads() ../lib/CppUTest/src/UtestPlatformGcc.cpp:175 (acl_test+0x000000932582)
6:     intel#6 Utest::run(TestResult&) ../lib/CppUTest/src/Utest.cpp:83 (acl_test+0x00000092fdd4)
6:     intel#7 Utest::runOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:69 (acl_test+0x00000092fcf2)
6:     intel#8 Utest::executePlatformSpecificRunOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/UtestPlatformGcc.cpp:100 (acl_test+0x0000009322be)
6:     intel#9 Utest::runOneTestWithPlugins(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:63 (acl_test+0x00000092fc77)
6:     intel#10 TestRegistry::runAllTests(TestResult&) ../lib/CppUTest/src/TestRegistry.cpp:72 (acl_test+0x00000092f124)
6:     intel#11 CommandLineTestRunner::runAllTests() ../lib/CppUTest/src/CommandLineTestRunner.cpp:105 (acl_test+0x00000092947d)
6:     intel#12 CommandLineTestRunner::runAllTestsMain() ../lib/CppUTest/src/CommandLineTestRunner.cpp:81 (acl_test+0x0000009295bd)
6:     intel#13 CommandLineTestRunner::RunAllTests(int, char const**) ../lib/CppUTest/src/CommandLineTestRunner.cpp:63 (acl_test+0x0000009296e4)
6:     intel#14 main ../test/acl_test.cpp:90 (acl_test+0x00000090d2d4)
6:
6:   Previous write of size 8 at 0x7b3c000003d0 by main thread (mutexes: write M41):
6:     #0 operator delete(void*) /nfs/site/disks/swip_pr_1/kbrunham/p4root/depot/devenv/tools/gcc/7.4.0/work/src/libsanitizer/tsan/tsan_new_delete.cc:71 (libtsan.so.0+0x00000006af04)
6:     intel#1 acl_delete<_cl_command_queue> ../include/acl_support.h:31 (acl_test+0x00000041118c)
6:     intel#2 acl_free_cl_command_queue ../src/acl_command_queue.cpp:99 (acl_test+0x00000041118c)
6:     intel#3 acl_delete_command_queue ../src/acl_command_queue.cpp:1005 (acl_test+0x000000411461)
6:     intel#4 clReleaseCommandQueueIntelFPGA ../src/acl_command_queue.cpp:288 (acl_test+0x000000413a1e)
6:     intel#5 clReleaseCommandQueue ../src/acl_command_queue.cpp:297 (acl_test+0x000000413a6e)
6:     intel#6 acl_command_queue_after_context_release_Test::testBody() ../test/acl_command_queue_test.cpp:676 (acl_test+0x00000052447d)
6:     intel#7 Utest::executePlatformSpecificTestBody() ../lib/CppUTest/src/UtestPlatformGcc.cpp:82 (acl_test+0x0000009320a0)
6:     intel#8 Utest::runInThread() ../lib/CppUTest/src/Utest.cpp:99 (acl_test+0x00000092fe78)
6:     intel#9 acl_command_queue_after_context_release_Test::runInThreadOnCopy() ../test/acl_command_queue_test.cpp:622 (acl_test+0x000000538b4c)
6:     intel#10 Utest::executePlatformSpecificRunInThreads() ../lib/CppUTest/src/UtestPlatformGcc.cpp:175 (acl_test+0x000000932582)
6:     intel#11 Utest::run(TestResult&) ../lib/CppUTest/src/Utest.cpp:83 (acl_test+0x00000092fdd4)
6:     intel#12 Utest::runOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:69 (acl_test+0x00000092fcf2)
6:     intel#13 Utest::executePlatformSpecificRunOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/UtestPlatformGcc.cpp:100 (acl_test+0x0000009322be)
6:     intel#14 Utest::runOneTestWithPlugins(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:63 (acl_test+0x00000092fc77)
6:     intel#15 TestRegistry::runAllTests(TestResult&) ../lib/CppUTest/src/TestRegistry.cpp:72 (acl_test+0x00000092f124)
6:     intel#16 CommandLineTestRunner::runAllTests() ../lib/CppUTest/src/CommandLineTestRunner.cpp:105 (acl_test+0x00000092947d)
6:     intel#17 CommandLineTestRunner::runAllTestsMain() ../lib/CppUTest/src/CommandLineTestRunner.cpp:81 (acl_test+0x0000009295bd)
6:     intel#18 CommandLineTestRunner::RunAllTests(int, char const**) ../lib/CppUTest/src/CommandLineTestRunner.cpp:63 (acl_test+0x0000009296e4)
6:     intel#19 main ../test/acl_test.cpp:90 (acl_test+0x00000090d2d4)
6:
6:   Mutex M41 (0x000004dfc600) created at:
6:     #0 pthread_mutex_init /nfs/site/disks/swip_pr_1/kbrunham/p4root/depot/devenv/tools/gcc/7.4.0/work/src/libsanitizer/tsan/tsan_interceptors.cc:1117 (libtsan.so.0+0x0000000291fe)
6:     intel#1 acl_init_condvar ../lib/acl_threadsupport/src/acl_threadsupport.c:330 (acl_test+0x000000928951)
6:     intel#2 l_global_lock_init ../src/acl_thread.cpp:102 (acl_test+0x0000004fe4eb)
6:     intel#3 __libc_csu_init /home/abuild/rpmbuild/BUILD/glibc-2.22/csu/elf-init.c:88 (acl_test+0x00000093a06c)
6:
6: SUMMARY: ThreadSanitizer: heap-use-after-free ../include/acl_util.h:433 in acl_ref_count<_cl_command_queue*>
6: ==================
6: ==================
6: WARNING: ThreadSanitizer: heap-use-after-free (pid=2499)
6:   Read of size 8 at 0x7b3c000004b8 by main thread (mutexes: write M41):
6:     #0 int acl_is_valid_ptr<_cl_command_queue*>(_cl_command_queue* const&) ../include/acl_util.h:417 (acl_test+0x000000413780)
6:     intel#1 acl_command_queue_is_valid(_cl_command_queue*) ../src/acl_command_queue.cpp:553 (acl_test+0x000000413780)
6:     intel#2 acl_command_queue_after_context_release_Test::testBody() ../test/acl_command_queue_test.cpp:680 (acl_test+0x0000005247c5)
6:     intel#3 Utest::executePlatformSpecificTestBody() ../lib/CppUTest/src/UtestPlatformGcc.cpp:82 (acl_test+0x0000009320a0)
6:     intel#4 Utest::runInThread() ../lib/CppUTest/src/Utest.cpp:99 (acl_test+0x00000092fe78)
6:     intel#5 acl_command_queue_after_context_release_Test::runInThreadOnCopy() ../test/acl_command_queue_test.cpp:622 (acl_test+0x000000538b4c)
6:     intel#6 Utest::executePlatformSpecificRunInThreads() ../lib/CppUTest/src/UtestPlatformGcc.cpp:175 (acl_test+0x000000932582)
6:     intel#7 Utest::run(TestResult&) ../lib/CppUTest/src/Utest.cpp:83 (acl_test+0x00000092fdd4)
6:     intel#8 Utest::runOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:69 (acl_test+0x00000092fcf2)
6:     intel#9 Utest::executePlatformSpecificRunOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/UtestPlatformGcc.cpp:100 (acl_test+0x0000009322be)
6:     intel#10 Utest::runOneTestWithPlugins(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:63 (acl_test+0x00000092fc77)
6:     intel#11 TestRegistry::runAllTests(TestResult&) ../lib/CppUTest/src/TestRegistry.cpp:72 (acl_test+0x00000092f124)
6:     intel#12 CommandLineTestRunner::runAllTests() ../lib/CppUTest/src/CommandLineTestRunner.cpp:105 (acl_test+0x00000092947d)
6:     intel#13 CommandLineTestRunner::runAllTestsMain() ../lib/CppUTest/src/CommandLineTestRunner.cpp:81 (acl_test+0x0000009295bd)
6:     intel#14 CommandLineTestRunner::RunAllTests(int, char const**) ../lib/CppUTest/src/CommandLineTestRunner.cpp:63 (acl_test+0x0000009296e4)
6:     intel#15 main ../test/acl_test.cpp:90 (acl_test+0x00000090d2d4)
6:
6:   Previous write of size 8 at 0x7b3c000004b8 by main thread (mutexes: write M41):
6:     #0 operator delete(void*) /nfs/site/disks/swip_pr_1/kbrunham/p4root/depot/devenv/tools/gcc/7.4.0/work/src/libsanitizer/tsan/tsan_new_delete.cc:71 (libtsan.so.0+0x00000006af04)
6:     intel#1 acl_delete<_cl_command_queue> ../include/acl_support.h:31 (acl_test+0x00000041118c)
6:     intel#2 acl_free_cl_command_queue ../src/acl_command_queue.cpp:99 (acl_test+0x00000041118c)
6:     intel#3 acl_delete_command_queue ../src/acl_command_queue.cpp:1005 (acl_test+0x000000411461)
6:     intel#4 clReleaseCommandQueueIntelFPGA ../src/acl_command_queue.cpp:288 (acl_test+0x000000413a1e)
6:     intel#5 clReleaseCommandQueue ../src/acl_command_queue.cpp:297 (acl_test+0x000000413a6e)
6:     intel#6 acl_command_queue_after_context_release_Test::testBody() ../test/acl_command_queue_test.cpp:675 (acl_test+0x000000524379)
6:     intel#7 Utest::executePlatformSpecificTestBody() ../lib/CppUTest/src/UtestPlatformGcc.cpp:82 (acl_test+0x0000009320a0)
6:     intel#8 Utest::runInThread() ../lib/CppUTest/src/Utest.cpp:99 (acl_test+0x00000092fe78)
6:     intel#9 acl_command_queue_after_context_release_Test::runInThreadOnCopy() ../test/acl_command_queue_test.cpp:622 (acl_test+0x000000538b4c)
6:     intel#10 Utest::executePlatformSpecificRunInThreads() ../lib/CppUTest/src/UtestPlatformGcc.cpp:175 (acl_test+0x000000932582)
6:     intel#11 Utest::run(TestResult&) ../lib/CppUTest/src/Utest.cpp:83 (acl_test+0x00000092fdd4)
6:     intel#12 Utest::runOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:69 (acl_test+0x00000092fcf2)
6:     intel#13 Utest::executePlatformSpecificRunOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/UtestPlatformGcc.cpp:100 (acl_test+0x0000009322be)
6:     intel#14 Utest::runOneTestWithPlugins(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:63 (acl_test+0x00000092fc77)
6:     intel#15 TestRegistry::runAllTests(TestResult&) ../lib/CppUTest/src/TestRegistry.cpp:72 (acl_test+0x00000092f124)
6:     intel#16 CommandLineTestRunner::runAllTests() ../lib/CppUTest/src/CommandLineTestRunner.cpp:105 (acl_test+0x00000092947d)
6:     intel#17 CommandLineTestRunner::runAllTestsMain() ../lib/CppUTest/src/CommandLineTestRunner.cpp:81 (acl_test+0x0000009295bd)
6:     intel#18 CommandLineTestRunner::RunAllTests(int, char const**) ../lib/CppUTest/src/CommandLineTestRunner.cpp:63 (acl_test+0x0000009296e4)
6:     intel#19 main ../test/acl_test.cpp:90 (acl_test+0x00000090d2d4)
6:
6:   Mutex M41 (0x000004dfc600) created at:
6:     #0 pthread_mutex_init /nfs/site/disks/swip_pr_1/kbrunham/p4root/depot/devenv/tools/gcc/7.4.0/work/src/libsanitizer/tsan/tsan_interceptors.cc:1117 (libtsan.so.0+0x0000000291fe)
6:     intel#1 acl_init_condvar ../lib/acl_threadsupport/src/acl_threadsupport.c:330 (acl_test+0x000000928951)
6:     intel#2 l_global_lock_init ../src/acl_thread.cpp:102 (acl_test+0x0000004fe4eb)
6:     intel#3 __libc_csu_init /home/abuild/rpmbuild/BUILD/glibc-2.22/csu/elf-init.c:88 (acl_test+0x00000093a06c)
6:
6: SUMMARY: ThreadSanitizer: heap-use-after-free ../include/acl_util.h:417 in int acl_is_valid_ptr<_cl_command_queue*>(_cl_command_queue* const&)
6: ==================
6: ==================
6: WARNING: ThreadSanitizer: heap-use-after-free (pid=2499)
6:   Read of size 8 at 0x7b3c000003c8 by main thread (mutexes: write M41):
6:     #0 int acl_is_valid_ptr<_cl_command_queue*>(_cl_command_queue* const&) ../include/acl_util.h:417 (acl_test+0x000000413780)
6:     intel#1 acl_command_queue_is_valid(_cl_command_queue*) ../src/acl_command_queue.cpp:553 (acl_test+0x000000413780)
6:     intel#2 acl_command_queue_after_context_release_Test::testBody() ../test/acl_command_queue_test.cpp:681 (acl_test+0x00000052482f)
6:     intel#3 Utest::executePlatformSpecificTestBody() ../lib/CppUTest/src/UtestPlatformGcc.cpp:82 (acl_test+0x0000009320a0)
6:     intel#4 Utest::runInThread() ../lib/CppUTest/src/Utest.cpp:99 (acl_test+0x00000092fe78)
6:     intel#5 acl_command_queue_after_context_release_Test::runInThreadOnCopy() ../test/acl_command_queue_test.cpp:622 (acl_test+0x000000538b4c)
6:     intel#6 Utest::executePlatformSpecificRunInThreads() ../lib/CppUTest/src/UtestPlatformGcc.cpp:175 (acl_test+0x000000932582)
6:     intel#7 Utest::run(TestResult&) ../lib/CppUTest/src/Utest.cpp:83 (acl_test+0x00000092fdd4)
6:     intel#8 Utest::runOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:69 (acl_test+0x00000092fcf2)
6:     intel#9 Utest::executePlatformSpecificRunOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/UtestPlatformGcc.cpp:100 (acl_test+0x0000009322be)
6:     intel#10 Utest::runOneTestWithPlugins(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:63 (acl_test+0x00000092fc77)
6:     intel#11 TestRegistry::runAllTests(TestResult&) ../lib/CppUTest/src/TestRegistry.cpp:72 (acl_test+0x00000092f124)
6:     intel#12 CommandLineTestRunner::runAllTests() ../lib/CppUTest/src/CommandLineTestRunner.cpp:105 (acl_test+0x00000092947d)
6:     intel#13 CommandLineTestRunner::runAllTestsMain() ../lib/CppUTest/src/CommandLineTestRunner.cpp:81 (acl_test+0x0000009295bd)
6:     intel#14 CommandLineTestRunner::RunAllTests(int, char const**) ../lib/CppUTest/src/CommandLineTestRunner.cpp:63 (acl_test+0x0000009296e4)
6:     intel#15 main ../test/acl_test.cpp:90 (acl_test+0x00000090d2d4)
6:
6:   Previous write of size 8 at 0x7b3c000003c8 by main thread (mutexes: write M41):
6:     #0 operator delete(void*) /nfs/site/disks/swip_pr_1/kbrunham/p4root/depot/devenv/tools/gcc/7.4.0/work/src/libsanitizer/tsan/tsan_new_delete.cc:71 (libtsan.so.0+0x00000006af04)
6:     intel#1 acl_delete<_cl_command_queue> ../include/acl_support.h:31 (acl_test+0x00000041118c)
6:     intel#2 acl_free_cl_command_queue ../src/acl_command_queue.cpp:99 (acl_test+0x00000041118c)
6:     intel#3 acl_delete_command_queue ../src/acl_command_queue.cpp:1005 (acl_test+0x000000411461)
6:     intel#4 clReleaseCommandQueueIntelFPGA ../src/acl_command_queue.cpp:288 (acl_test+0x000000413a1e)
6:     intel#5 clReleaseCommandQueue ../src/acl_command_queue.cpp:297 (acl_test+0x000000413a6e)
6:     intel#6 acl_command_queue_after_context_release_Test::testBody() ../test/acl_command_queue_test.cpp:676 (acl_test+0x00000052447d)
6:     intel#7 Utest::executePlatformSpecificTestBody() ../lib/CppUTest/src/UtestPlatformGcc.cpp:82 (acl_test+0x0000009320a0)
6:     intel#8 Utest::runInThread() ../lib/CppUTest/src/Utest.cpp:99 (acl_test+0x00000092fe78)
6:     intel#9 acl_command_queue_after_context_release_Test::runInThreadOnCopy() ../test/acl_command_queue_test.cpp:622 (acl_test+0x000000538b4c)
6:     intel#10 Utest::executePlatformSpecificRunInThreads() ../lib/CppUTest/src/UtestPlatformGcc.cpp:175 (acl_test+0x000000932582)
6:     intel#11 Utest::run(TestResult&) ../lib/CppUTest/src/Utest.cpp:83 (acl_test+0x00000092fdd4)
6:     intel#12 Utest::runOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:69 (acl_test+0x00000092fcf2)
6:     intel#13 Utest::executePlatformSpecificRunOneTest(TestPlugin*, TestResult&) ../lib/CppUTest/src/UtestPlatformGcc.cpp:100 (acl_test+0x0000009322be)
6:     intel#14 Utest::runOneTestWithPlugins(TestPlugin*, TestResult&) ../lib/CppUTest/src/Utest.cpp:63 (acl_test+0x00000092fc77)
6:     intel#15 TestRegistry::runAllTests(TestResult&) ../lib/CppUTest/src/TestRegistry.cpp:72 (acl_test+0x00000092f124)
6:     intel#16 CommandLineTestRunner::runAllTests() ../lib/CppUTest/src/CommandLineTestRunner.cpp:105 (acl_test+0x00000092947d)
6:     intel#17 CommandLineTestRunner::runAllTestsMain() ../lib/CppUTest/src/CommandLineTestRunner.cpp:81 (acl_test+0x0000009295bd)
6:     intel#18 CommandLineTestRunner::RunAllTests(int, char const**) ../lib/CppUTest/src/CommandLineTestRunner.cpp:63 (acl_test+0x0000009296e4)
6:     intel#19 main ../test/acl_test.cpp:90 (acl_test+0x00000090d2d4)
6:
6:   Mutex M41 (0x000004dfc600) created at:
6:     #0 pthread_mutex_init /nfs/site/disks/swip_pr_1/kbrunham/p4root/depot/devenv/tools/gcc/7.4.0/work/src/libsanitizer/tsan/tsan_interceptors.cc:1117 (libtsan.so.0+0x0000000291fe)
6:     intel#1 acl_init_condvar ../lib/acl_threadsupport/src/acl_threadsupport.c:330 (acl_test+0x000000928951)
6:     intel#2 l_global_lock_init ../src/acl_thread.cpp:102 (acl_test+0x0000004fe4eb)
6:     intel#3 __libc_csu_init /home/abuild/rpmbuild/BUILD/glibc-2.22/csu/elf-init.c:88 (acl_test+0x00000093a06c)
6:
6: SUMMARY: ThreadSanitizer: heap-use-after-free ../include/acl_util.h:417 in int acl_is_valid_ptr<_cl_command_queue*>(_cl_command_queue* const&)
6: ==================
6:  - 227 ms
pcolberg pushed a commit to sherry-yuan/fpga-runtime-for-opencl that referenced this issue Feb 18, 2022
As found in intel#71, tsan reported several issues in the acl_test

Currently when release command queue are called (which frees the memory) subsequent still checks the values at the same address which cause tsan to report heap-use-after-free.
pcolberg pushed a commit that referenced this issue Feb 18, 2022
------------------------------------------------------

As found in #71, tsan reported several issues in the acl_test

Currently when release command queue are called (which frees the memory) subsequent still checks the values at the same address which cause tsan to report heap-use-after-free.
@pcolberg
Copy link
Contributor

Reopening since the issues in acl_threadsupport_test still need to be resolved as a prerequisite for #63. This is not a third-party library and can be modified. Even if it were a third-party library, the issue would need to be resolved, ideally upstream 🙂

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
2 participants