yibaini / thread-sanitizer

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

ThreadSanitizer with GCC 4.9.0 - TSAN_OPTIONS ignored #95

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I am using ThreadSanitizer on a 'C' program compiled with GCC 4.9.0 running 
under Ubuntu 2.04.

ThreadSanitizer itself is working properly, but it is ignoring the TSAN_OPTIONS 
environment variable.

This issue occurs whether I am running the program from within GDB 7.4. or 
directly from the command line.

I have set the environment variable from the command line before running GDB as 
follows:

export TSAN_OPTIONS=report_bugs=0

I have confirmed that TSAN_OPTIONS is set as expected, both from "printenv" on 
the command line and also from within the "C" program under test, using 
getenv().

For example the above setting, which should stop bugs from being reported by 
ThreadSanitizer, fails to stop bugs being reported by ThreadSanitizer.

Some other switches I have tested are suppressions and log_path.

TSAN Compile switches are -fsanitize=thread -fno-omit-frame-pointer -fPIE

TSAN Link switches -fsanitize=thread -fno-omit-frame-pointer -pie

Any help or ideas are appreciated.

Original issue reported on code.google.com by gblaneyT...@gmail.com on 18 Aug 2015 at 9:57

GoogleCodeExporter commented 9 years ago
 I have noticed that TSAN_OPTIONS is written as TSAN_OPTIONS=report_bugs=0 ./a.out with an addition "./a.out" at the end. An explanation on this is appreciated. There is really no place where the TSAN_OPTIONS syntax is fully explained. Also as an additional clue I am seeing the same issue of options being ignored recognizing with ASAN_OPTIONS. –  GCB Toronto 17 hours ago  

The additional parameter is likely the name of the process for which the 
options will be applied. I have tried adding this, but the result is the same: 
options specified by TSAN_OPTIONS are ignored by ThreadSanitizer. 

Original comment by gblaneyT...@gmail.com on 18 Aug 2015 at 9:58

GoogleCodeExporter commented 9 years ago
Hi,

Yes, the additional parameter is executable name. When you invoke:

$ ENVVAR=somevalue ./executable

this runs the ./executable with ENVVAR=somevalue in environment.

I've just tested this with gcc4.8 and gcc6.0. I don't have gcc4.9. Please 
provide full reproduction instructions (sequence of commands you execute) and 
source code.

Original comment by dvyu...@google.com on 18 Aug 2015 at 10:09

GoogleCodeExporter commented 9 years ago
Hi, thanks for the reply. I am going to try GCC 4.8. Also my project is quite 
large so I am assembling some example source code for this and I will reply 
with this shortly.

My execution procedure is as follows:

$ export TSAN_OPTIONS=report_bugs=0
$ printenv TSAN_OPTIONS
$ report_bugs=0
$ ./MY_EXECUTABLE.BIN
$ <various TSAN errors are reported>

I also tried:

$ TSAN_OPTIONS=report_bugs=0 ./MY_EXECUTABLE.BIN
$ <various TSAN errors are reported>

Original comment by gblaneyT...@gmail.com on 18 Aug 2015 at 4:19

GoogleCodeExporter commented 9 years ago
Note: the line above under printenv TSAN_OPTIONS ("report_bugs=0") is the 
output of printenv.

Original comment by gblaneyT...@gmail.com on 18 Aug 2015 at 4:25

GoogleCodeExporter commented 9 years ago
Please build and run the following program:

#include <pthread.h>

int x;

void *thread(void *a) {
  x = 42;
  return 0;
}

int main() {
  pthread_t t;
  pthread_create(&t, 0, thread, 0);
  x = 43;
  pthread_join(t, 0);
}

Using the following commands:

$ gcc test.c -fsanitize=thread -pie -fPIE -ltsan -lpthread -lrt -ldl
$ ./a.out
$ TSAN_OPTIONS=report_bugs=0 ./a.out

What does it output?

Original comment by dvyu...@google.com on 18 Aug 2015 at 4:35

GoogleCodeExporter commented 9 years ago
That does work! And once I copy and paste your options into my own little demo 
program, that I was about to send you, it worked too. That is, I am now able to 
control the output of ThreadSanitize.

The output of a.out is at the bottom of this post.

This is the abbreviated compiler and linker command lines of my original 
project. Is the issue with my command line obvious from a quick look?

gcc -save-temps -gdwarf-3 I../src/LIB/Include -O0 -fstack-protector-all -g 
-Werror -c -fmessage-length=0 -fsanitize=thread -fno-omit-frame-pointer -fPIE 
-fPIC -MMD -MP -MF"src/LIB/cmpltime.d" -MT"src/LIB/cmpltime.d" 
-o"src/LIB/cmpltime.o" "../src/LIB/cmpltime.c"

gcc -o "TSI40V1"      -lpthread -lrt -fsanitize=thread -fno-omit-frame-pointer 
-pie

Thanks for you assistance.

============

output of a.out:

==================
WARNING: ThreadSanitizer: data race (pid=29165)
  Write of size 4 at 0x7f2e51e6a2ec by thread T1:
    #0 thread /root/tsan_demo 2/tsan-demo/src/tsan-demo.c:6 (a.out+0x000000000b27)
    #1 <null> <null> (libtsan.so.0+0x000000026629)

  Previous write of size 4 at 0x7f2e51e6a2ec by main thread:
    #0 main /root/tsan_demo 2/tsan-demo/src/tsan-demo.c:13 (a.out+0x000000000b89)

  Location is global 'x' of size 4 at 0x7f2e51e6a2ec (a.out+0x0000002012ec)

  Thread T1 (tid=29167, running) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x00000002a4f7)
    #1 main /root/tsan_demo 2/tsan-demo/src/tsan-demo.c:12 (a.out+0x000000000b7a)

SUMMARY: ThreadSanitizer: data race /root/tsan_demo 
2/tsan-demo/src/tsan-demo.c:6 thread
==================
ThreadSanitizer: reported 1 warnings

Original comment by gblaneyT...@gmail.com on 18 Aug 2015 at 8:19

GoogleCodeExporter commented 9 years ago
I am surprised that your commands work for you. The first command misses "-" 
before "I../src/LIB/Include". The second command missed name of object file. 
Are you sure that are exact commands that you run?
Also I don't think "-fno-omit-frame-pointer" affects linking in any way.  Also, 
"-fPIE -fPIC" looks strange, one of these options takes precedence.

I've just checked the following commands:
$ gcc -save-temps -gdwarf-3 I../src/LIB/Include -O0 -fstack-protector-all -g 
-Werror -c -fmessage-length=0 -fsanitize=thread -fno-omit-frame-pointer -fPIE 
-fPIC /tmp/111.c
$ gcc 111.o -o "TSI40V1" -lpthread -lrt -ltsan -fno-omit-frame-pointer -pie

And they worked for me (successful build and TSAN_OPTIONS works).

Original comment by dvyu...@google.com on 18 Aug 2015 at 8:30

GoogleCodeExporter commented 9 years ago
I tweak the original project compiler and linker command lines as follows based 
on you recommendation (this is an Eclipse project):

gcc -fsanitize=thread -pie -fPIE -ltsan -lpthread -lrt -ldl 
-I../src/LIB/Include -O0 -fstack-protector-all -g -Werror -c -fmessage-length=0 
-MMD -MP -MF"src/version.d" -MT"src/version.d" -o"src/version.o" 
"../src/version.c"

gcc  -fsanitize=thread -pie -fPIE -ltsan -lpthread -lrt -ldl -o "TSI40V1"  
./src/LIB/comm/zmodem/copy_lfs.o 

Original comment by gblaneyT...@gmail.com on 18 Aug 2015 at 8:48

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
(The above tweak does not work) It is quite a large project. I am not sure if 
that is a factor.

Original comment by gblaneyT...@gmail.com on 18 Aug 2015 at 8:51

GoogleCodeExporter commented 9 years ago
I abbreviated the actual commands since they are quite large with a lot of -D 
arguments and a lot of object files. I may have delete an object file entry.

Original comment by gblaneyT...@gmail.com on 18 Aug 2015 at 8:54

GoogleCodeExporter commented 9 years ago
Is it possible that your original large program starts other subprocesses and 
does not pass environment to them? Maybe the race reports are printed from 
subprocesses?

What if you run your program with TSAN_OPTIONS=verbosity=100 environment var? 
Do you see any additional output from tsan? If yes, then TSAN_OPTIONS work for 
this program.

Original comment by dvyu...@google.com on 18 Aug 2015 at 9:09

GoogleCodeExporter commented 9 years ago
With "verbosity=100" I am seeing 

checking shadow region 0x000000001000-0x010000000000
  checking pointer 0x000000001000 -> 0x080000004000
  checking pointer 0x000000001001 -> 0x080000004000
  checking pointer 0x004000000bff -> 0x090000002fe0

that I do not see with "verbosity=1" or with "report_bugs=0".

I think the verbosity is making a difference and yet "report_bugs=0" does not 
turn off the bug reporting

Some samples are below. There is a lot of output and my copy and paste cutoff 
in each case is arbitrary.

//////////////////////////////////////////////
verbosity=100
//////////////////////////////////////////////
checking shadow region 0x000000001000-0x010000000000
  checking pointer 0x000000001000 -> 0x080000004000
  checking pointer 0x000000001001 -> 0x080000004000
  checking pointer 0x004000000bff -> 0x090000002fe0
  checking pointer 0x004000000c00 -> 0x090000003000
  checking pointer 0x004000000c01 -> 0x090000003000
  checking pointer 0x0080000007ff -> 0x0a0000001fe0
  checking pointer 0x008000000800 -> 0x0a0000002000
  checking pointer 0x008000000801 -> 0x0a0000002000
  checking pointer 0x00c0000003ff -> 0x0b0000000fe0
  checking pointer 0x00c000000400 -> 0x0b0000001000
  checking pointer 0x00c000000401 -> 0x0b0000001000
  checking pointer 0x00ffffffffff -> 0x0bffffffffe0
checking shadow region 0x7e8000000000-0x800000000000
  checking pointer 0x7e8000000000 -> 0x020000000000
  checking pointer 0x7e8000000001 -> 0x020000000000
  checking pointer 0x7edfffffffff -> 0x037fffffffe0
  checking pointer 0x7ee000000000 -> 0x038000000000
  checking pointer 0x7ee000000001 -> 0x038000000000
  checking pointer 0x7f3fffffffff -> 0x04ffffffffe0
  checking pointer 0x7f4000000000 -> 0x050000000000
  checking pointer 0x7f4000000001 -> 0x050000000000
  checking pointer 0x7f9fffffffff -> 0x067fffffffe0
  checking pointer 0x7fa000000000 -> 0x068000000000
  checking pointer 0x7fa000000001 -> 0x068000000000
  checking pointer 0x7fffffffffff -> 0x07ffffffffe0
checking shadow region 0x7d0000000000-0x7e0000000000
  checking pointer 0x7d0000000000 -> 0x0c0000000000
  checking pointer 0x7d0000000001 -> 0x0c0000000000
  checking pointer 0x7d3fffffffff -> 0x0cffffffffe0
  checking pointer 0x7d4000000000 -> 0x0d0000000000
  checking pointer 0x7d4000000001 -> 0x0d0000000000
  checking pointer 0x7d7fffffffff -> 0x0dffffffffe0
  checking pointer 0x7d8000000000 -> 0x0e0000000000
  checking pointer 0x7d8000000001 -> 0x0e0000000000
  checking pointer 0x7dbfffffffff -> 0x0effffffffe0
  checking pointer 0x7dc000000000 -> 0x0f0000000000
  checking pointer 0x7dc000000001 -> 0x0f0000000000
  checking pointer 0x7dffffffffff -> 0x0fffffffffe0
***** Running under ThreadSanitizer v2 (pid 1906) *****
INFO: ThreadSanitizer ignores mlock/mlockall/munlock/munlockall

TSIARG file found

cfg transfer enable state 0 

269 001 SOFTWARE: FtpStartServer-417 Undefined function executed
FTP server startup failed
Sanitizer: increasing stacksize 20480->565824
==================
WARNING: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) 
(pid=1906)
    #0 pthread_mutex_unlock <null> (libtsan.so.0+0x00000003834b)
    #1 ResetEvent ../src/LIB/comm/win32func2linux.c:963 (TSI40V1+0x000000202fcf)
    #2 gblnet_wait_start ../src/LIB/comm/tcpip/gblnet6.c:4783 (TSI40V1+0x00000014dd53)
    #3 gblnet_startup_event ../src/LIB/comm/tcpip/gblnet6.c:4896 (TSI40V1+0x00000014e3c9)
    #4 gblnet_wait_init ../src/LIB/comm/tcpip/gblnet6.c:4765 (TSI40V1+0x00000014dc58)
    #5 gblnet_init ../src/LIB/comm/tcpip/gblnet6.c:598 (TSI40V1+0x00000013b474)
    #6 main ../src/LIB/Core/main.c:376 (TSI40V1+0x00000088dfcf)

  Location is global 'tsi_handle' of size 14942208 at 0x7f798735c900 (TSI40V1+0x00000331c890)

  Mutex M2139 (0x7f79874d7890) created at:
    #0 pthread_mutex_init <null> (libtsan.so.0+0x00000002af15)
    #1 _CreateEvent ../src/LIB/comm/win32func2linux.c:879 (TSI40V1+0x000000202b3b)
    #2 gblnet_wait_init ../src/LIB/comm/tcpip/gblnet6.c:4761 (TSI40V1+0x00000014dc16)
    #3 gblnet_init ../src/LIB/comm/tcpip/gblnet6.c:598 (TSI40V1+0x00000013b474)
    #4 main ../src/LIB/Core/main.c:376 (TSI40V1+0x00000088dfcf)

SUMMARY: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) 
??:0 __interceptor_pthread_mutex_unlock
==================

953 001 WARNING: tsinet13.c-7588 Null TCP handle==================
WARNING: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) 
(pid=1906)
    #0 pthread_mutex_unlock <null> (libtsan.so.0+0x00000003834b)
    #1 ResetEvent ../src/LIB/comm/win32func2linux.c:963 (TSI40V1+0x000000202fcf)
    #2 cfg_setup_wait_start ../src/LIB/Core/cfg_save.c:707 (TSI40V1+0x00000084b98e)
    #3 cfgbuf_init ../src/LIB/Core/cfgbuf.c:127 (TSI40V1+0x00000086da62)
    #4 main ../src/LIB/Core/main.c:406 (TSI40V1+0x00000088e0a3)

  Location is global 'tsi_handle' of size 14942208 at 0x7f798735c900 (TSI40V1+0x000003331770)

  Mutex M2212 (0x7f79874ec770) created at:
    #0 pthread_mutex_init <null> (libtsan.so.0+0x00000002af15)
    #1 _CreateEvent ../src/LIB/comm/win32func2linux.c:879 (TSI40V1+0x000000202b3b)
    #2 cfg_init ../src/LIB/Core/cfg_save.c:659 (TSI40V1+0x00000084b69e)
    #3 main ../src/LIB/Core/main.c:389 (TSI40V1+0x00000088e00e)

SUMMARY: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) 
??:0 __interceptor_pthread_mutex_unlock
==================
==================
WARNING: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) 
(pid=1906)
    #0 pthread_mutex_unlock <null> (libtsan.so.0+0x00000003834b)
    #1 ResetEvent ../src/LIB/comm/win32func2linux.c:963 (TSI40V1+0x000000202fcf)
    #2 gpiport_setup_wait_start ../src/LIB/GPI/gpiport2.c:3052 (TSI40V1+0x00000074c298)
    #3 cfgbuf_init ../src/LIB/Core/cfgbuf.c:129 (TSI40V1+0x00000086da67)
    #4 main ../src/LIB/Core/main.c:406 (TSI40V1+0x00000088e0a3)

  Location is global 'tsi_handle' of size 14942208 at 0x7f798735c900 (TSI40V1+0x0000033b5d58)

  Mutex M3401 (0x7f7987570d58) created at:
    #0 pthread_mutex_init <null> (libtsan.so.0+0x00000002af15)
    #1 _CreateEvent ../src/LIB/comm/win32func2linux.c:879 (TSI40V1+0x000000202b3b)
    #2 gpiport_wait_init ../src/LIB/GPI/gpiport2.c:3033 (TSI40V1+0x00000074c0d6)
    #3 gpiport_init ../src/LIB/GPI/gpiport2.c:251 (TSI40V1+0x000000740966)
    #4 main ../src/LIB/Core/main.c:403 (TSI40V1+0x00000088e078)

SUMMARY: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) 
??:0 __interceptor_pthread_mutex_unlock

//////////////////////////////////////////////
verbosity=1
//////////////////////////////////////////////

***** Running under ThreadSanitizer v2 (pid 1886) *****
INFO: ThreadSanitizer ignores mlock/mlockall/munlock/munlockall

TSIARG file found

cfg transfer enable state 0 

270 001 SOFTWARE: FtpStartServer-417 Undefined function executed
FTP server startup failed
Sanitizer: increasing stacksize 20480->565824
==================
WARNING: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) 
(pid=1886)
    #0 pthread_mutex_unlock <null> (libtsan.so.0+0x00000003834b)
    #1 ResetEvent ../src/LIB/comm/win32func2linux.c:963 (TSI40V1+0x000000202fcf)
    #2 gblnet_wait_start ../src/LIB/comm/tcpip/gblnet6.c:4783 (TSI40V1+0x00000014dd53)
    #3 gblnet_startup_event ../src/LIB/comm/tcpip/gblnet6.c:4896 (TSI40V1+0x00000014e3c9)
    #4 gblnet_wait_init ../src/LIB/comm/tcpip/gblnet6.c:4765 (TSI40V1+0x00000014dc58)
    #5 gblnet_init ../src/LIB/comm/tcpip/gblnet6.c:598 (TSI40V1+0x00000013b474)
    #6 main ../src/LIB/Core/main.c:376 (TSI40V1+0x00000088dfcf)

  Location is global 'tsi_handle' of size 14942208 at 0x7ff573c4b900 (TSI40V1+0x00000331c890)

  Mutex M2139 (0x7ff573dc6890) created at:
    #0 pthread_mutex_init <null> (libtsan.so.0+0x00000002af15)
    #1 _CreateEvent ../src/LIB/comm/win32func2linux.c:879 (TSI40V1+0x000000202b3b)
    #2 gblnet_wait_init ../src/LIB/comm/tcpip/gblnet6.c:4761 (TSI40V1+0x00000014dc16)
    #3 gblnet_init ../src/LIB/comm/tcpip/gblnet6.c:598 (TSI40V1+0x00000013b474)
    #4 main ../src/LIB/Core/main.c:376 (TSI40V1+0x00000088dfcf)

SUMMARY: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) 
??:0 __interceptor_pthread_mutex_unlock
==================

797 001 WARNING: tsinet13.c-7588 Null TCP handle==================
WARNING: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) 
(pid=1886)
    #0 pthread_mutex_unlock <null> (libtsan.so.0+0x00000003834b)
    #1 ResetEvent ../src/LIB/comm/win32func2linux.c:963 (TSI40V1+0x000000202fcf)
    #2 cfg_setup_wait_start ../src/LIB/Core/cfg_save.c:707 (TSI40V1+0x00000084b98e)
    #3 cfgbuf_init ../src/LIB/Core/cfgbuf.c:127 (TSI40V1+0x00000086da62)
    #4 main ../src/LIB/Core/main.c:406 (TSI40V1+0x00000088e0a3)

  Location is global 'tsi_handle' of size 14942208 at 0x7ff573c4b900 (TSI40V1+0x000003331770)

  Mutex M2212 (0x7ff573ddb770) created at:
    #0 pthread_mutex_init <null> (libtsan.so.0+0x00000002af15)
    #1 _CreateEvent ../src/LIB/comm/win32func2linux.c:879 (TSI40V1+0x000000202b3b)
    #2 cfg_init ../src/LIB/Core/cfg_save.c:659 (TSI40V1+0x00000084b69e)
    #3 main ../src/LIB/Core/main.c:389 (TSI40V1+0x00000088e00e)

SUMMARY: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) 
??:0 __interceptor_pthread_mutex_unlock
==================
==================
WARNING: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) 
(pid=1886)
    #0 pthread_mutex_unlock <null> (libtsan.so.0+0x00000003834b)
    #1 ResetEvent ../src/LIB/comm/win32func2linux.c:963 (TSI40V1+0x000000202fcf)
    #2 gpiport_setup_wait_start ../src/LIB/GPI/gpiport2.c:3052 (TSI40V1+0x00000074c298)
    #3 cfgbuf_init ../src/LIB/Core/cfgbuf.c:129 (TSI40V1+0x00000086da67)
    #4 main ../src/LIB/Core/main.c:406 (TSI40V1+0x00000088e0a3)

  Location is global 'tsi_handle' of size 14942208 at 0x7ff573c4b900 (TSI40V1+0x0000033b5d58)

  Mutex M3401 (0x7ff573e5fd58) created at:
    #0 pthread_mutex_init <null> (libtsan.so.0+0x00000002af15)
    #1 _CreateEvent ../src/LIB/comm/win32func2linux.c:879 (TSI40V1+0x000000202b3b)
    #2 gpiport_wait_init ../src/LIB/GPI/gpiport2.c:3033 (TSI40V1+0x00000074c0d6)
    #3 gpiport_init ../src/LIB/GPI/gpiport2.c:251 (TSI40V1+0x000000740966)
    #4 main ../src/LIB/Core/main.c:403 (TSI40V1+0x00000088e078)

SUMMARY: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) 
??:0 __interceptor_pthread_mutex_unlock
==================
Sanitizer: increasing stacksize 20480->565824

//////////////////////////////////////////////
report_bugs=0
//////////////////////////////////////////////
TSIARG file found

cfg transfer enable state 0 

270 001 SOFTWARE: FtpStartServer-417 Undefined function executed
FTP server startup failed
==================
WARNING: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) 
(pid=2163)
    #0 pthread_mutex_unlock <null> (libtsan.so.0+0x00000003834b)
    #1 ResetEvent ../src/LIB/comm/win32func2linux.c:963 (TSI40V1+0x000000202fcf)
    #2 gblnet_wait_start ../src/LIB/comm/tcpip/gblnet6.c:4783 (TSI40V1+0x00000014dd53)
    #3 gblnet_startup_event ../src/LIB/comm/tcpip/gblnet6.c:4896 (TSI40V1+0x00000014e3c9)
    #4 gblnet_wait_init ../src/LIB/comm/tcpip/gblnet6.c:4765 (TSI40V1+0x00000014dc58)
    #5 gblnet_init ../src/LIB/comm/tcpip/gblnet6.c:598 (TSI40V1+0x00000013b474)
    #6 main ../src/LIB/Core/main.c:376 (TSI40V1+0x00000088dfcf)

  Location is global 'tsi_handle' of size 14942208 at 0x7f50e1ee8900 (TSI40V1+0x00000331c890)

  Mutex M2139 (0x7f50e2063890) created at:
    #0 pthread_mutex_init <null> (libtsan.so.0+0x00000002af15)
    #1 _CreateEvent ../src/LIB/comm/win32func2linux.c:879 (TSI40V1+0x000000202b3b)
    #2 gblnet_wait_init ../src/LIB/comm/tcpip/gblnet6.c:4761 (TSI40V1+0x00000014dc16)
    #3 gblnet_init ../src/LIB/comm/tcpip/gblnet6.c:598 (TSI40V1+0x00000013b474)
    #4 main ../src/LIB/Core/main.c:376 (TSI40V1+0x00000088dfcf)

SUMMARY: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) 
??:0 __interceptor_pthread_mutex_unlock
==================

792 001 WARNING: tsinet13.c-7588 Null TCP handle==================
WARNING: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) 
(pid=2163)
    #0 pthread_mutex_unlock <null> (libtsan.so.0+0x00000003834b)
    #1 ResetEvent ../src/LIB/comm/win32func2linux.c:963 (TSI40V1+0x000000202fcf)
    #2 cfg_setup_wait_start ../src/LIB/Core/cfg_save.c:707 (TSI40V1+0x00000084b98e)
    #3 cfgbuf_init ../src/LIB/Core/cfgbuf.c:127 (TSI40V1+0x00000086da62)
    #4 main ../src/LIB/Core/main.c:406 (TSI40V1+0x00000088e0a3)

  Location is global 'tsi_handle' of size 14942208 at 0x7f50e1ee8900 (TSI40V1+0x000003331770)

  Mutex M2212 (0x7f50e2078770) created at:
    #0 pthread_mutex_init <null> (libtsan.so.0+0x00000002af15)
    #1 _CreateEvent ../src/LIB/comm/win32func2linux.c:879 (TSI40V1+0x000000202b3b)
    #2 cfg_init ../src/LIB/Core/cfg_save.c:659 (TSI40V1+0x00000084b69e)
    #3 main ../src/LIB/Core/main.c:389 (TSI40V1+0x00000088e00e)

SUMMARY: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) 
??:0 __interceptor_pthread_mutex_unlock
==================
==================
WARNING: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) 
(pid=2163)
    #0 pthread_mutex_unlock <null> (libtsan.so.0+0x00000003834b)
    #1 ResetEvent ../src/LIB/comm/win32func2linux.c:963 (TSI40V1+0x000000202fcf)
    #2 gpiport_setup_wait_start ../src/LIB/GPI/gpiport2.c:3052 (TSI40V1+0x00000074c298)
    #3 cfgbuf_init ../src/LIB/Core/cfgbuf.c:129 (TSI40V1+0x00000086da67)
    #4 main ../src/LIB/Core/main.c:406 (TSI40V1+0x00000088e0a3)

  Location is global 'tsi_handle' of size 14942208 at 0x7f50e1ee8900 (TSI40V1+0x0000033b5d58)

  Mutex M3401 (0x7f50e20fcd58) created at:
    #0 pthread_mutex_init <null> (libtsan.so.0+0x00000002af15)
    #1 _CreateEvent ../src/LIB/comm/win32func2linux.c:879 (TSI40V1+0x000000202b3b)
    #2 gpiport_wait_init ../src/LIB/GPI/gpiport2.c:3033 (TSI40V1+0x00000074c0d6)
    #3 gpiport_init ../src/LIB/GPI/gpiport2.c:251 (TSI40V1+0x000000740966)
    #4 main ../src/LIB/Core/main.c:403 (TSI40V1+0x00000088e078)

SUMMARY: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) 
??:0 __interceptor_pthread_mutex_unlock
==================

Original comment by gblaneyT...@gmail.com on 18 Aug 2015 at 9:50

GoogleCodeExporter commented 9 years ago
The reports come from a different processes. You can see different values of 
pid in reports. I bet you don't propagate environment to subprocesses.

Original comment by dvyu...@google.com on 18 Aug 2015 at 10:16

GoogleCodeExporter commented 9 years ago
By a "process", do you mean a thread? The only function used here for creating 
a new thread or a process is pthread_create(). I am betting the different pid 
numbers are the LWPs for the individual threads in my program.

I called getenv() from one of my threads other than main and it was able to 
print out the contents of TSAN_OPTIONS.

Original comment by gblaneyT...@gmail.com on 18 Aug 2015 at 11:00