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 libstdc++/51504] New: Data race hunting instructions in manual do not work


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

             Bug #: 51504
           Summary: Data race hunting instructions in manual do not work
    Classification: Unclassified
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: bart.vanassche@gmail.com


Created attachment 26048
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26048
Test program that allows to reproduce the bug

According to the instructions in the "Data Race Hunting" paragraph
(http://gcc.gnu.org/onlinedocs/libstdc++/manual/debug.html), the following
should be sufficient to avoid false positive data race reports on multithreaded
programs:

#include <valgrind/drd.h>
#define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(addr) \
  ANNOTATE_HAPPENS_BEFORE(addr)
#define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(addr) \
  ANNOTATE_HAPPENS_AFTER(addr)
#define _GLIBCXX_EXTERN_TEMPLATE -1

Unfortunately that's not sufficient. The output I obtained for a small test
program is:

$ ./vg-in-place --tool=drd drd/tests/std_thread 2>&1 | grep -E 'Confl|SUMMARY'
==18629== Conflicting store by thread 1 at 0x0433e02c size 4
==18629== Conflicting store by thread 1 at 0x0433e02c size 4
==18629== Conflicting load by thread 1 at 0x0433e034 size 4
==18629== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 16 from 6)

After digging around a little I found out that in the created thread the 
reference count of the _Impl object is decremented from inside libstdc++. So no
matter which macros are defined in the code that includes <thread>, that
reference count decrementing code won't be annotated. Moving the implementation
of the function execute_native_thread_routine() from src/thread.cc to
include/std/thread might fix this (haven't tried this).

Detailed information:
$ uname -a
Linux f16 3.1.4-1.fc16.i686.PAE #1 SMP Tue Nov 29 12:23:00 UTC 2011 i686 i686
i386 GNU/Linux
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i686-redhat-linux/4.6.2/lto-wrapper
Target: i686-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-gnu-unique-object
--enable-linker-build-id
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin
--enable-java-awt=gtk --disable-dssi
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
--with-ppl --with-cloog --with-tune=generic --with-arch=i686
--build=i686-redhat-linux
Thread model: posix
gcc version 4.6.2 20111027 (Red Hat 4.6.2-1) (GCC)

This bug can be reproduced by running the following commands on a system with
gcc 4.6.x:
svn co -r12291 svn://svn.valgrind.org/valgrind/trunk valgrind
cd valgrind
./autogen.sh
./configure
make -s
make -s check
./vg-in-place --tool=drd drd/tests/std_thread


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