This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug sanitizer/57507] New: gcc 4.8: thread sanitizer: std::thread false(?) positive


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57507

            Bug ID: 57507
           Summary: gcc 4.8: thread sanitizer: std::thread false(?)
                    positive
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alxchk at alxchk dot me
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org

$ cat test.cpp
#include <thread>

int main(int argc, char *argv[])
{
    std::thread t([](){});
    t.join();

    return 0;
}

$ LC_ALL=C g++ --version
g++ (Gentoo Hardened 4.8.0 p1.2, pie-0.5.5) 4.8.0
Copyright (C) 2013 Free Software Foundation, Inc.

$ g++ -o test test.cpp --std=gnu++11 -pthread -fsanitize=thread -ggdb3 -O0
$ ./test
==================
WARNING: ThreadSanitizer: data race (pid=14129)
  Write of size 8 at 0x7d080000bfc8 by thread T1:
    #0 <null> <null>:0 (libtsan.so.0+0x000000020dc0)
    #1 deallocate
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/ext/new_allocator.h:110
(exe+0x000000002b42)
    #2 deallocate
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/alloc_traits.h:377
(exe+0x000000002972)
    #3 _M_destroy
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/shared_ptr_base.h:417
(exe+0x000000003336)
    #4 <null> <null>:0 (libstdc++.so.6+0x0000000c8cea)

  Previous atomic write of size 4 at 0x7d080000bfc8 by main thread:
    #0 <null> <null>:0 (libtsan.so.0+0x00000000dfc5)
    #1 __exchange_and_add
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/ext/atomicity.h:47
(exe+0x000000001898)
    #2 __exchange_and_add_dispatch
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/ext/atomicity.h:80
(exe+0x000000001995)
    #3 std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release()
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/shared_ptr_base.h:141
(exe+0x000000003c86)
    #4 std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count()
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/shared_ptr_base.h:553
(exe+0x000000003c2d)
    #5 std::__shared_ptr<std::thread::_Impl_base,
(__gnu_cxx::_Lock_policy)2>::~__shared_ptr()
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/shared_ptr_base.h:810
(exe+0x000000003aae)
    #6 std::shared_ptr<std::thread::_Impl_base>::~shared_ptr()
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/shared_ptr.h:93
(exe+0x000000003afc)
    #7 thread<main(int, char**)::__lambda0>
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/thread:135
(exe+0x000000001c10)
    #8 main /tmp/test.cpp:5 (exe+0x000000001a3e)

  Location is heap block of size 56 at 0x7d080000bfc0 allocated by main thread:
    #0 <null> <null>:0 (libtsan.so.0+0x000000020ad2)
    #1 allocate
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/ext/new_allocator.h:104
(exe+0x000000002a5b)
    #2 allocate
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/alloc_traits.h:351
(exe+0x000000002881)
    #3 __shared_count<std::thread::_Impl<std::_Bind_simple<main(int,
char**)::__lambda0()> >,
std::allocator<std::thread::_Impl<std::_Bind_simple<main(int,
char**)::__lambda0()> > >, std::_Bind_simple<main(int, char**)::__lambda0()> >
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/shared_ptr_base.h:519
(exe+0x0000000026e5)
    #4
__shared_ptr<std::allocator<std::thread::_Impl<std::_Bind_simple<main(int,
char**)::__lambda0()> > >, std::_Bind_simple<main(int, char**)::__lambda0()> >
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/shared_ptr_base.h:986
(exe+0x0000000025a1)
    #5 shared_ptr<std::allocator<std::thread::_Impl<std::_Bind_simple<main(int,
char**)::__lambda0()> > >, std::_Bind_simple<main(int, char**)::__lambda0()> >
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/shared_ptr.h:316
(exe+0x000000002511)
    #6 allocate_shared<std::thread::_Impl<std::_Bind_simple<main(int,
char**)::__lambda0()> >,
std::allocator<std::thread::_Impl<std::_Bind_simple<main(int,
char**)::__lambda0()> > >, std::_Bind_simple<main(int, char**)::__lambda0()> >
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/shared_ptr.h:598
(exe+0x000000002422)
    #7 make_shared<std::thread::_Impl<std::_Bind_simple<main(int,
char**)::__lambda0()> >, std::_Bind_simple<main(int, char**)::__lambda0()> >
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/shared_ptr.h:614
(exe+0x00000000225a)
    #8 _M_make_routine<std::_Bind_simple<main(int, char**)::__lambda0()> >
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/thread:193
(exe+0x000000001fa2)
    #9 thread<main(int, char**)::__lambda0>
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/thread:135
(exe+0x000000001bde)
    #10 main /tmp/test.cpp:5 (exe+0x000000001a3e)

  Thread T1 (tid=14130, running) created by main thread at:
    #0 <null> <null>:0 (libtsan.so.0+0x000000022cdb)
    #1 <null> <null>:0 (libstdc++.so.6+0x0000000c8ef6)
    #2 main /tmp/test.cpp:5 (exe+0x000000001a3e)

SUMMARY: ThreadSanitizer: data race ??:0 ??
==================
ThreadSanitizer: reported 1 warnings


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]