https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92731
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Component|c++ |libstdc++
Resolution|--- |INVALID
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I think this is a false positive, as mentioned in the ThreadSanitizer FAQ:
https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual#faq
The problem is that TSan can only instrument the code it sees (as explained in
<https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual#non-instrumented-code>)
and the reference counting for exception_ptr is inside the runtime, which is
built without TSan
If I use -fsanitize=thread to instrument the testcase *and* all the relevant
sources from libstdc++ then the program runs forever without sanitizer errors:
g++ 92731.cc
$GCC_SRC/libstdc++-v3/libsupc++/eh_{ptr,terminate,{term,unex}_handler}.cc
-pthread -fsanitize=thread
A more user-friendly solution is to use a copy of libstdc++.so built with tsan,
e.g. by building gcc with:
--enable-libstdcxx-debug
--enable-libstdcxx-debug-flags='-Og -g -fsanitize=thread'
and then using $PREFIX/lib64/debug/libstdc++.so.6 at runtime.
A simpler option is to just set TSAN_OPTIONS=ignore_noninstrumented_modules=1
in the environment when running your program.