[LLVMbugs] [Bug 20003] Crashing on pthread_join
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Jun 11 13:41:48 PDT 2014
http://llvm.org/bugs/show_bug.cgi?id=20003
Richard Smith <richard-llvm at metafoo.co.uk> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |richard-llvm at metafoo.co.uk
Resolution|--- |INVALID
--- Comment #1 from Richard Smith <richard-llvm at metafoo.co.uk> ---
Your code has a data race. Building with -fsanitize=thread gives this:
WARNING: ThreadSanitizer: data race (pid=24036)
Read of size 8 at 0x7d080000efc0 by main thread:
#0 printMatrix <null>:0 (a.out+0x00000009f486)
#1 main <null>:0 (a.out+0x0000000a056d)
Previous write of size 8 at 0x7d080000efc0 by thread T1:
#0 multMatrix <null>:0 (a.out+0x00000009e499)
#1 multMatrixThread <null>:0 (a.out+0x00000009e881)
As if synchronized via sleep:
#0 sleep
/usr/local/google/home/richardsmith/build/llvm-3/src/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:243
(a.out+0x000000035d20)
#1 main <null>:0 (a.out+0x0000000a0366)
Location is heap block of size 32 at 0x7d080000efc0 allocated by main thread:
#0 malloc
/usr/local/google/home/richardsmith/build/llvm-3/src/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:460
(a.out+0x0000000370ad)
#1 allocMatrix <null>:0 (a.out+0x00000009dcf1)
#2 main <null>:0 (a.out+0x00000009fac7)
Thread T1 (tid=24039, finished) created by main thread at:
#0 pthread_create
/usr/local/google/home/richardsmith/build/llvm-3/src/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:842
(a.out+0x00000003ac6f)
#1 main <null>:0 (a.out+0x0000000a02fa)
SUMMARY: ThreadSanitizer: data race ??:0 printMatrix
Note that you increment 'i' at the wrong place in your loop, so you never
actually join the thread you created. Fixing that bug removes the data race and
makes your code work.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140611/a2e3dbca/attachment.html>
More information about the llvm-bugs
mailing list