public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/51504] New: Data race hunting instructions in manual do not work
@ 2011-12-11 20:27 bart.vanassche at gmail dot com
  2011-12-11 20:30 ` [Bug libstdc++/51504] " bart.vanassche at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: bart.vanassche at gmail dot com @ 2011-12-11 20:27 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libstdc++/51504] Data race hunting instructions in manual do not work
  2011-12-11 20:27 [Bug libstdc++/51504] New: Data race hunting instructions in manual do not work bart.vanassche at gmail dot com
@ 2011-12-11 20:30 ` bart.vanassche at gmail dot com
  2011-12-11 20:43 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: bart.vanassche at gmail dot com @ 2011-12-11 20:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Bart Van Assche <bart.vanassche at gmail dot com> 2011-12-11 20:26:47 UTC ---
Created attachment 26049
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26049
Detailed DRD output for the test program


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libstdc++/51504] Data race hunting instructions in manual do not work
  2011-12-11 20:27 [Bug libstdc++/51504] New: Data race hunting instructions in manual do not work bart.vanassche at gmail dot com
  2011-12-11 20:30 ` [Bug libstdc++/51504] " bart.vanassche at gmail dot com
@ 2011-12-11 20:43 ` paolo.carlini at oracle dot com
  2011-12-23 22:11 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-12-11 20:43 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-12-11 20:36:01 UTC ---
You didn't read carefully the second paragraph, which clearly explain that you
have to rebuild the .so. In other terms, this is a known limitation.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libstdc++/51504] Data race hunting instructions in manual do not work
  2011-12-11 20:27 [Bug libstdc++/51504] New: Data race hunting instructions in manual do not work bart.vanassche at gmail dot com
  2011-12-11 20:30 ` [Bug libstdc++/51504] " bart.vanassche at gmail dot com
  2011-12-11 20:43 ` paolo.carlini at oracle dot com
@ 2011-12-23 22:11 ` redi at gcc dot gnu.org
  2011-12-23 23:46 ` paolo.carlini at oracle dot com
  2012-01-06  1:26 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2011-12-23 22:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-12-23 22:09:10 UTC ---
N.B. you don't have to rebuild the whole .so you can rebuild just thread.cc and
link thread.o into your program. The dynamic linker will do symbol
interposition and use the std::thread::_M_start_thread symbol from your program
instead of the one from libstdc++.so


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libstdc++/51504] Data race hunting instructions in manual do not work
  2011-12-11 20:27 [Bug libstdc++/51504] New: Data race hunting instructions in manual do not work bart.vanassche at gmail dot com
                   ` (2 preceding siblings ...)
  2011-12-23 22:11 ` redi at gcc dot gnu.org
@ 2011-12-23 23:46 ` paolo.carlini at oracle dot com
  2012-01-06  1:26 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-12-23 23:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-12-23 23:33:59 UTC ---
Nice tip.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libstdc++/51504] Data race hunting instructions in manual do not work
  2011-12-11 20:27 [Bug libstdc++/51504] New: Data race hunting instructions in manual do not work bart.vanassche at gmail dot com
                   ` (3 preceding siblings ...)
  2011-12-23 23:46 ` paolo.carlini at oracle dot com
@ 2012-01-06  1:26 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2012-01-06  1:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-01-06 01:26:12 UTC ---
Author: redi
Date: Fri Jan  6 01:26:06 2012
New Revision: 182943

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182943
Log:
    PR libstdc++/51504
    * doc/xml/manual/debug.xml: Suggest using symbol interposition
    to override symbols using annotation macros.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/doc/xml/manual/debug.xml


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-01-06  1:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-11 20:27 [Bug libstdc++/51504] New: Data race hunting instructions in manual do not work bart.vanassche at gmail dot com
2011-12-11 20:30 ` [Bug libstdc++/51504] " bart.vanassche at gmail dot com
2011-12-11 20:43 ` paolo.carlini at oracle dot com
2011-12-23 22:11 ` redi at gcc dot gnu.org
2011-12-23 23:46 ` paolo.carlini at oracle dot com
2012-01-06  1:26 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).