cwgreene / thread-sanitizer

Automatically exported from code.google.com/p/thread-sanitizer
0 stars 0 forks source link

Segfaul t in this simple code. What am I doing incorrectly? #65

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Build the example
2. Run the example

What is the expected output? What do you see instead?
No segfault?  I would hope.  Or maybe I don't understand something about 
threads.

What version of the product are you using? On what operating system?

3.11.0-19-generic #33-Ubuntu SMP Tue Mar 11 18:48:34 UTC 2014 x86_64 x86_64 
x86_64 GNU/Linux

Please provide any additional information below.
Segmentation fault (core dumped)

Original issue reported on code.google.com by mojowi...@gmail.com on 7 Jun 2014 at 2:46

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by mojowi...@gmail.com on 7 Jun 2014 at 2:47

Attachments:

GoogleCodeExporter commented 9 years ago
mkdir build
cd build
cmake ..
make
./test

-> segfault

Original comment by mojowi...@gmail.com on 7 Jun 2014 at 2:48

GoogleCodeExporter commented 9 years ago
Additionally, I cannot use valgrind without it complaining:

 Warning: set address range perms: large range

Original comment by mojowi...@gmail.com on 7 Jun 2014 at 2:52

GoogleCodeExporter commented 9 years ago
And valgrind seems to fall over with:

FATAL: ThreadSanitizer can not mmap the shadow memory (something is mapped at 
0x108000 < 0x7cf000000000)
FATAL: Make sure to compile with -fPIE and to link with -pie.

But I'm pretty sure this is being compiled with pie....

Original comment by mojowi...@gmail.com on 7 Jun 2014 at 2:53

GoogleCodeExporter commented 9 years ago
Naturally if I don't compile with tsan, pie, etc, then the code runs quite 
happily and doesn't seem to have issues.  So if such simple code is broken by 
thread-sanitizer, how am I supposed to use it?

Original comment by mojowi...@gmail.com on 7 Jun 2014 at 2:55

GoogleCodeExporter commented 9 years ago
Actually, repeated locking and unlocking a mutex (without any additional 
threads) makes the program crash under tsan. I observed this bug also on 
clang-3.3. However, it was fixed on clang-3.4. Probably, it will be eventually 
fixed under gcc as well.

Original comment by yegor.de...@gmail.com on 7 Jun 2014 at 8:17

GoogleCodeExporter commented 9 years ago
What version are you using?

Works fine for me on:

clang version 3.5.0 (209757)
Target: x86_64-unknown-linux-gnu

Original comment by dvyu...@google.com on 9 Jun 2014 at 9:22

GoogleCodeExporter commented 9 years ago
I tried on ubuntu 12.04 and ubuntu 14.04 -- tsan works. 
Maybe there is some issue on your Linux distribution. 
What Linux distro are you using?

As for valgrind: tsan and valgrind can not work together.

Original comment by konstant...@gmail.com on 9 Jun 2014 at 9:56

GoogleCodeExporter commented 9 years ago
gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) 

I will try it out with clang when I get the chance.  Thanks for the help.

Original comment by mojowi...@gmail.com on 9 Jun 2014 at 12:59

GoogleCodeExporter commented 9 years ago
Please reopen if you still see this issue with a more recent version of tsan.

Original comment by dvyu...@google.com on 2 Sep 2014 at 2:11