Status: New
Owner: ----

New issue 3160 by [email protected]: Data race between Thread::Join() and ThreadEntry()
http://code.google.com/p/v8/issues/detail?id=3160

/usr/local/google/v8-bleeding/out/x64.release/cctest test-cpu-profiler/CodeEvents --nobreak-on-abort --nofold-constants --testing_serialization_file=/usr/local/google/v8-bleeding/out/.serdes/serdes_CodeEvents
==================
WARNING: ThreadSanitizer: data race (pid=15477)
  Read of size 8 at 0x7d040000b770 by main thread:
#0 v8::internal::Thread::Join() /usr/local/google/v8-bleeding/out/../src/platform-posix.cc:652 (cctest+0x00000121fb82) #1 v8::internal::ProfilerEventsProcessor::StopSynchronously() /usr/local/google/v8-bleeding/out/../src/cpu-profiler.cc:83 (cctest+0x000000cb77f6) #2 TestCodeEvents() /usr/local/google/v8-bleeding/out/../test/cctest/test-cpu-profiler.cc:164 (cctest+0x000000aef33c) #3 CcTest::Run() /usr/local/google/v8-bleeding/out/../test/cctest/cctest.cc:83 (cctest+0x000000a19f4b) #4 main /usr/local/google/v8-bleeding/out/../test/cctest/cctest.cc:178 (cctest+0x000000a1a489)

  Previous write of size 8 at 0x7d040000b770 by thread T6:
    [failed to restore the stack]

Location is heap block of size 8 at 0x7d040000b770 allocated by main thread: #0 malloc /usr/local/google/asan/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:469 (cctest+0x0000009b702d) #1 v8::internal::Malloced::New(unsigned long) /usr/local/google/v8-bleeding/out/../src/allocation.cc:43 (cctest+0x000000c13fc5) #2 operator new /usr/local/google/v8-bleeding/out/../src/allocation.h:44 (cctest+0x00000121f8b0) #3 v8::internal::Thread::Thread(v8::internal::Thread::Options const&) /usr/local/google/v8-bleeding/out/../src/platform-posix.cc:570 (cctest+0x00000121f8b0) #4 v8::internal::ProfilerEventsProcessor::ProfilerEventsProcessor(v8::internal::ProfileGenerator*, v8::internal::Sampler*, v8::internal::TimeDelta) /usr/local/google/v8-bleeding/out/../src/cpu-profiler.cc:55 (cctest+0x000000cb71af) #5 TestCodeEvents() /usr/local/google/v8-bleeding/out/../test/cctest/test-cpu-profiler.cc:144 (cctest+0x000000aef0e8) #6 CcTest::Run() /usr/local/google/v8-bleeding/out/../test/cctest/cctest.cc:83 (cctest+0x000000a19f4b) #7 main /usr/local/google/v8-bleeding/out/../test/cctest/cctest.cc:178 (cctest+0x000000a1a489)

Thread T6 'v8:ProfEvntProc' (tid=15484, running) created by main thread at: #0 pthread_create /usr/local/google/asan/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:865 (cctest+0x0000009baee6) #1 v8::internal::Thread::Start() /usr/local/google/v8-bleeding/out/../src/platform-posix.cc:642 (cctest+0x00000121fabc) #2 TestCodeEvents() /usr/local/google/v8-bleeding/out/../test/cctest/test-cpu-profiler.cc:146 (cctest+0x000000aef0f0) #3 CcTest::Run() /usr/local/google/v8-bleeding/out/../test/cctest/cctest.cc:83 (cctest+0x000000a19f4b) #4 main /usr/local/google/v8-bleeding/out/../test/cctest/cctest.cc:178 (cctest+0x000000a1a489)

SUMMARY: ThreadSanitizer: data race /usr/local/google/v8-bleeding/out/../src/platform-posix.cc:652 v8::internal::Thread::Join()
================================================


Despite the previous write stack is missing, I can tell that's the write of pthread_self() into thread->data()->thread_ in ThreadEntry() (src/platform-posix.cc) - the report disappears when I remove that write. This write isn't synchronized with accesses to thread_ from other threads (including the write performed by pthread_create() in the parent thread), so it may be dangerous for a third thread to read thread_ before the caller of pthread_create() has returned. This makes the value of thread->data()->thread_ written in ThreadEntry() only useful in the child thread that performs ThreadEntry() - but there's pthread_self() for that, maybe use it instead?

One may also possibly imagine a pthread_create implementation (or a compiler optimization of NPTL, Linuxthreads or Bionic threads) that assumes nobody is writing to the first parameter (e.g. it may re-read that from memory).

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to