runt18 / data-race-test

Automatically exported from code.google.com/p/data-race-test
0 stars 0 forks source link

Unittest stops on an assert pthread_attr_setdetachstate(&attr, detached) #103

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
OS: Darwin, OS X 10.6.8 64-bit in 32-bit mode

I'm starting the demo test with the following command:
sudo ./valgrind --tool=tsan 
/Users/Shared/threadsanitizer/drt/unittest/bin/demo_tests-darwin-x86-O1

and getting the following output:

==97820== ThreadSanitizer, a data race detector
==97820== Copyright (C) 2008-2010, and GNU GPL'd, by Google Inc.
==97820== Using Valgrind-3.8.0.SVN and LibVEX; rerun with -h for copyright info 
==97820== Command: 
/Users/Shared/threadsanitizer/drt/unittest/bin/demo_tests-darwin-x86-O1
==97820==
==97820== ThreadSanitizerValgrind r4379: hybrid=no ==97820== INFO: Allocating 
192Mb (24 * 8M) for Segments.
==97820== INFO: Will allocate up to 320Mb for 'previous' stack traces.
--97820-- 
/Users/Shared/threadsanitizer/drt/unittest/bin/demo_tests-darwin-x86-O1:
--97820-- dSYM directory is missing; consider using --dsymutil=yes
--97820-- 
/Users/Shared/threadsanitizer/drt/tsan/bin/vgpreload_tsan-x86-darwin.so:
--97820-- dSYM directory is missing; consider using --dsymutil=yes [==========] 
Running 15 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 15 tests from DemoTests
[ RUN      ] DemoTests.RaceReportDemoTest
Assertion failed: (0 == pthread_attr_setdetachstate(&attr, detached)), function 
Start, file thread_wrappers_pthread.h, line 341.
==97820==
==97820== Process terminating with default action of signal 6 (SIGABRT)
==97820==    at 0x1107C5A: __kill (in /usr/lib/libSystem.B.dylib)
==97820==    by 0x119A5A4: raise (in /usr/lib/libSystem.B.dylib)
==97820==    by 0x11B06E3: abort (in /usr/lib/libSystem.B.dylib)
==97820==    by 0x119D20E: __assert_rtn (in /usr/lib/libSystem.B.dylib)
==97820==    by 0xAEDA: MyThread::Start(bool) (in 
/Users/Shared/threadsanitizer/drt/unittest/bin/demo_tests-darwin-x86-O1)
==97820==    by 0x852B: 
RaceReportDemoTest::DemoTests_RaceReportDemoTest_Test::TestBody() (in 
/Users/Shared/threadsanitizer/drt/unittest/bin/demo_tests-darwin-x86-O1)
==97820==    by 0x162D3: testing::Test::Run() (in 
/Users/Shared/threadsanitizer/drt/unittest/bin/demo_tests-darwin-x86-O1)
==97820==    by 0x1927D: testing::internal::TestInfoImpl::Run() (in 
/Users/Shared/threadsanitizer/drt/unittest/bin/demo_tests-darwin-x86-O1)
==97820==    by 0x19378: testing::TestCase::Run() (in 
/Users/Shared/threadsanitizer/drt/unittest/bin/demo_tests-darwin-x86-O1)
==97820==    by 0x1961D: testing::internal::UnitTestImpl::RunAllTests() (in 
/Users/Shared/threadsanitizer/drt/unittest/bin/demo_tests-darwin-x86-O1)
==97820==    by 0x19749: testing::UnitTest::Run() (in 
/Users/Shared/threadsanitizer/drt/unittest/bin/demo_tests-darwin-x86-O1)
==97820==    by 0x86E4: main (in 
/Users/Shared/threadsanitizer/drt/unittest/bin/demo_tests-darwin-x86-O1)
==97820==
==97820== used_suppression: 2 dyld tries to unlock an invalid mutex when 
adding/removing image.
==97820== ThreadSanitizer summary: reported 0 warning(s) (0 race(s)) 
Abort trap 

Is there some workaround for this problem?

Original issue reported on code.google.com by kutuzov....@gmail.com on 18 Jun 2012 at 9:16

GoogleCodeExporter commented 8 years ago
To work around this you can find the corresponding line in the source code 
(line 341 in thread_wrappers_pthread.h) and replace the CHECK with some code 
that prints the result of pthread_attr_setdetachstate(). Most certainly you can 
just comment this line out, but printing the error code will give us an idea 
about what's going on.

Original comment by ramosian.glider@gmail.com on 18 Jun 2012 at 9:29

GoogleCodeExporter commented 8 years ago
The pthread_attr_setdetachstate function returns an error code 22 on my system 
(EINVAL, Invalid argument).
I commented this line and I got an output for the demo unit test after that. 
Thank you.

Original comment by kutuzov....@gmail.com on 19 Jun 2012 at 12:05