This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Unexpected value-at for NULL'd pointer with pthreads
- From: Jeffrey Walton <noloader at gmail dot com>
- To: Kyle Harper <kylejharper at gmail dot com>
- Cc: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Fri, 21 Aug 2015 19:13:24 -0400
- Subject: Re: Unexpected value-at for NULL'd pointer with pthreads
- Authentication-results: sourceware.org; auth=none
- References: <CAPcbWWxx3g9Uk9sn5jgG1GgmxSk1fjy5ybHKuRMzdKN3LJqt2Q at mail dot gmail dot com> <CAH8yC8nSNMGkbLWWcToBX6ZP5ygFFVqjKOmjq_pnvvFmfnxqSA at mail dot gmail dot com> <CAH6eHdSw84L3t9AqUjwGkvEU=4knZJvAod+d72OgusP0F5q0pA at mail dot gmail dot com> <CAPcbWWx-CQpJQvKHdHkObJ4wRv=9idRi1PaJuJ0nScMM7o6E_g at mail dot gmail dot com>
- Reply-to: noloader at gmail dot com
>> Without looking at the code, I suggest trying GCC's -sanitize=thread option and/or valgrind's helgrind tool.
>
> I wasn't able to get -fsanitize=thread to compile. I moved to a VM
> with gcc 4.8+, installed libtsan0 (Trusty) and added the other flags
> (-pie etc) but it kept complaining the __tsan functions were
> undefined. Am I missing something to get this working?
I seem to recall having to install libubsan and libasan for the
Undefined Behavior and Address sanitizers (the ones I use). Maybe you
need to install libtsan or similar?
All you should need to do is add -fsanitize=thread to CFLAGS or
CXXFLAGS. If you are linking through the compiler driver, then the
CFLAGS or CXXFLAGS should be present with -fsanitize=thread, too. If
you are linking directly through LD, then I think -fsanitize=thread
needs to be provided in LDFLAGS.
Jeff