https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87457

            Bug ID: 87457
           Summary: thread sanitizer false positive on virtual destructor
           Product: gcc
           Version: 8.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: SebastiansPublicAddress at googlemail dot com
  Target Milestone: ---

Created attachment 44759
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44759&action=edit
source code to reproduce the bug

reproduce like this:

$ g++ -g -fno-omit-frame-pointer -fsanitize=undefined -fsanitize=thread -o
tsan_reproduce tsan_reproduce.cpp

$ ./tsan_reproduce
==================
WARNING: ThreadSanitizer: data race (pid=19509)
  Write of size 8 at 0x7b0400000800 by thread T2:
    #0 pipe <null> (libtsan.so.0+0x2f079)
    #1 <null> <null> (libubsan.so.1+0x1aaed)
    #2 void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void
(*&&)()) /usr/include/c++/8/bits/invoke.h:60 (tsan_reproduce+0x3efc)
    #3 std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void
(*&&)()) /usr/include/c++/8/bits/invoke.h:95 (tsan_reproduce+0x38e4)
    #4 decltype (__invoke((_S_declval<0ul>)()))
std::thread::_Invoker<std::tuple<void (*)()>
>::_M_invoke<0ul>(std::_Index_tuple<0ul>) /usr/include/c++/8/thread:244
(tsan_reproduce+0x569f)
    #5 std::thread::_Invoker<std::tuple<void (*)()> >::operator()()
/usr/include/c++/8/thread:253 (tsan_reproduce+0x55b7)
    #6 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> >
>::_M_run() /usr/include/c++/8/thread:196 (tsan_reproduce+0x554c)
    #7 <null> <null> (libstdc++.so.6+0xbbafe)

  Previous write of size 8 at 0x7b0400000800 by thread T1:
    #0 pipe <null> (libtsan.so.0+0x2f079)
    #1 <null> <null> (libubsan.so.1+0x1aaed)
    #2 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> >
>::~_State_impl() /usr/include/c++/8/thread:188 (tsan_reproduce+0x54a3)
    #3 <null> <null> (libstdc++.so.6+0xbbb07)

  Thread T2 (tid=19512, running) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x2be2b)
    #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State,
std::default_delete<std::thread::_State> >, void (*)()) <null>
(libstdc++.so.6+0xbbd84)
    #2 main
/home/sebastian/projects/photoalbum/lib/sqdbcpp/tsan_reproduce.cpp:18
(tsan_reproduce+0x346f)

  Thread T1 (tid=19511, finished) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x2be2b)
    #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State,
std::default_delete<std::thread::_State> >, void (*)()) <null>
(libstdc++.so.6+0xbbd84)
    #2 main
/home/sebastian/projects/photoalbum/lib/sqdbcpp/tsan_reproduce.cpp:17
(tsan_reproduce+0x345c)

SUMMARY: ThreadSanitizer: data race
(/usr/lib/x86_64-linux-gnu/libtsan.so.0+0x2f079) in pipe
==================
ThreadSanitizer: reported 1 warnings




My system:

$ uname -a
Linux roc-lin 4.18.0-1-amd64 #1 SMP Debian 4.18.8-1 (2018-09-18) x86_64
GNU/Linux

$ g++ --version
g++ (Debian 8.2.0-7) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Reply via email to