>
> #include <pthread.h>
> #include <string>
> #include <sstream>
>
> void *threadEntry(void *threadid)
> {
> long tid;
> tid = (long)threadid;
> std::string myString;
> for (int i = 0; i<5; i++) {
> myString.clear();
> pthread_yield();
> }
> pthread_exit(NULL);
> }
>
> int main (int argc, char *argv[])
> {
> pthread_t threads[2];
> int rc;
> long t;
>
> std::ostringstream dummy;
> dummy << 0;
> for(t=0; t<2; t++) {
> rc = pthread_create(&threads[t], NULL, threadEntry, (void
> *)t);
> }
> pthread_exit(NULL);
> }
>
> ==19065== drd, a thread error detector
> ==19065== Copyright (C) 2006-2009, and GNU GPL'd, by Bart Van Assche.
> ==19065== Using Valgrind-3.5.0-Debian and LibVEX; rerun with -h for
> copyright info
> ==19065== Command: ./a.out
> ==19065==
> ==19065== Thread 3:
> ==19065== Conflicting load by thread 3 at 0x05134160 size 8
> ==19065== at 0x4EDF1D7: std::string::clear() (in
> /usr/lib/libstdc++.so.6.0.13)
> ==19065== by 0x400A5B: threadEntry(void*) (threads.cpp:12)
> ==19065== by 0x4C32870: vgDrd_thread_wrapper (drd_pthread_intercepts.c:272)
> ==19065== by 0x55E8A03: start_thread (pthread_create.c:300)
> ==19065== by 0x58DD80C: clone (clone.S:112)
> ==19065== Allocation context: BSS section of /usr/lib/libstdc++.so.6.0.13
> ==19065== Other segment start (thread 2)
> ==19065== at 0x58DD7D1: clone (clone.S:84)
> ==19065== by 0x55E893F: ??? (allocatestack.c:743)
> ==19065== by 0x676D90F: ???
> ==19065== Other segment end (thread 2)
> ==19065== at 0x58ACEB7: sched_yield (in /lib/libc-2.10.1.so)
> ==19065== by 0x400A60: threadEntry(void*) (threads.cpp:13)
> ==19065== by 0x4C32870: vgDrd_thread_wrapper (drd_pthread_intercepts.c:272)
> ==19065== by 0x55E8A03: start_thread (pthread_create.c:300)
> ==19065== by 0x58DD80C: clone (clone.S:112)
> ==19065==
> ==19065== Conflicting load by thread 3 at 0x05134160 size 8
> ==19065== at 0x4EDE907: std::string::_M_mutate(unsigned long,
> unsigned long, unsigned long) (in /usr/lib/libstdc++.so.6.0.13)
> ==19065== by 0x400A5B: threadEntry(void*) (threads.cpp:12)
> ==19065== by 0x4C32870: vgDrd_thread_wrapper (drd_pthread_intercepts.c:272)
> ==19065== by 0x55E8A03: start_thread (pthread_create.c:300)
> ==19065== by 0x58DD80C: clone (clone.S:112)
> ==19065== Allocation context: BSS section of /usr/lib/libstdc++.so.6.0.13
> ==19065== Other segment start (thread 2)
> ==19065== at 0x58DD7D1: clone (clone.S:84)
> ==19065== by 0x55E893F: ??? (allocatestack.c:743)
> ==19065== by 0x676D90F: ???
> ==19065== Other segment end (thread 2)
> ==19065== at 0x58ACEB7: sched_yield (in /lib/libc-2.10.1.so)
> ==19065== by 0x400A60: threadEntry(void*) (threads.cpp:13)
> ==19065== by 0x4C32870: vgDrd_thread_wrapper (drd_pthread_intercepts.c:272)
> ==19065== by 0x55E8A03: start_thread (pthread_create.c:300)
> ==19065== by 0x58DD80C: clone (clone.S:112)
> ==19065==
> ==19065== Conflicting load by thread 3 at 0x05134170 size 4
> ==19065== at 0x4EDE9B0: std::string::_M_mutate(unsigned long,
> unsigned long, unsigned long) (in /usr/lib/libstdc++.so.6.0.13)
> ==19065== by 0x400A5B: threadEntry(void*) (threads.cpp:12)
> ==19065== by 0x4C32870: vgDrd_thread_wrapper (drd_pthread_intercepts.c:272)
> ==19065== by 0x55E8A03: start_thread (pthread_create.c:300)
> ==19065== by 0x58DD80C: clone (clone.S:112)
> ==19065== Allocation context: BSS section of /usr/lib/libstdc++.so.6.0.13
> ==19065== Other segment start (thread 2)
> ==19065== at 0x58DD7D1: clone (clone.S:84)
> ==19065== by 0x55E893F: ??? (allocatestack.c:743)
> ==19065== by 0x676D90F: ???
> ==19065== Other segment end (thread 2)
> ==19065== at 0x58ACEB7: sched_yield (in /lib/libc-2.10.1.so)
> ==19065== by 0x400A60: threadEntry(void*) (threads.cpp:13)
> ==19065== by 0x4C32870: vgDrd_thread_wrapper (drd_pthread_intercepts.c:272)
> ==19065== by 0x55E8A03: start_thread (pthread_create.c:300)
> ==19065== by 0x58DD80C: clone (clone.S:112)
> ==19065==
> ==19065== Conflicting store by thread 3 at 0x05134170 size 4
> ==19065== at 0x4EDE97D: std::string::_M_mutate(unsigned long,
> unsigned long, unsigned long) (in /usr/lib/libstdc++.so.6.0.13)
> ==19065== by 0x400A5B: threadEntry(void*) (threads.cpp:12)
> ==19065== by 0x4C32870: vgDrd_thread_wrapper (drd_pthread_intercepts.c:272)
> ==19065== by 0x55E8A03: start_thread (pthread_create.c:300)
> ==19065== by 0x58DD80C: clone (clone.S:112)
> ==19065== Allocation context: BSS section of /usr/lib/libstdc++.so.6.0.13
> ==19065== Other segment start (thread 2)
> ==19065== at 0x58DD7D1: clone (clone.S:84)
> ==19065== by 0x55E893F: ??? (allocatestack.c:743)
> ==19065== by 0x676D90F: ???
> ==19065== Other segment end (thread 2)
> ==19065== at 0x58ACEB7: sched_yield (in /lib/libc-2.10.1.so)
> ==19065== by 0x400A60: threadEntry(void*) (threads.cpp:13)
> ==19065== by 0x4C32870: vgDrd_thread_wrapper (drd_pthread_intercepts.c:272)
> ==19065== by 0x55E8A03: start_thread (pthread_create.c:300)
> ==19065== by 0x58DD80C: clone (clone.S:112)
> ==19065==
> ==19065== Conflicting store by thread 3 at 0x05134160 size 8
> ==19065== at 0x4EDE984: std::string::_M_mutate(unsigned long,
> unsigned long, unsigned long) (in /usr/lib/libstdc++.so.6.0.13)
> ==19065== by 0x400A5B: threadEntry(void*) (threads.cpp:12)
> ==19065== by 0x4C32870: vgDrd_thread_wrapper (drd_pthread_intercepts.c:272)
> ==19065== by 0x55E8A03: start_thread (pthread_create.c:300)
> ==19065== by 0x58DD80C: clone (clone.S:112)
> ==19065== Allocation context: BSS section of /usr/lib/libstdc++.so.6.0.13
> ==19065== Other segment start (thread 2)
> ==19065== at 0x58DD7D1: clone (clone.S:84)
> ==19065== by 0x55E893F: ??? (allocatestack.c:743)
> ==19065== by 0x676D90F: ???
> ==19065== Other segment end (thread 2)
> ==19065== at 0x58ACEB7: sched_yield (in /lib/libc-2.10.1.so)
> ==19065== by 0x400A60: threadEntry(void*) (threads.cpp:13)
> ==19065== by 0x4C32870: vgDrd_thread_wrapper (drd_pthread_intercepts.c:272)
> ==19065== by 0x55E8A03: start_thread (pthread_create.c:300)
> ==19065== by 0x58DD80C: clone (clone.S:112)
> ==19065==
> ==19065== Conflicting store by thread 3 at 0x05134178 size 1
> ==19065== at 0x4EDE987: std::string::_M_mutate(unsigned long,
> unsigned long, unsigned long) (in /usr/lib/libstdc++.so.6.0.13)
> ==19065== by 0x400A5B: threadEntry(void*) (threads.cpp:12)
> ==19065== by 0x4C32870: vgDrd_thread_wrapper (drd_pthread_intercepts.c:272)
> ==19065== by 0x55E8A03: start_thread (pthread_create.c:300)
> ==19065== by 0x58DD80C: clone (clone.S:112)
> ==19065== Allocation context: BSS section of /usr/lib/libstdc++.so.6.0.13
> ==19065== Other segment start (thread 2)
> ==19065== at 0x58DD7D1: clone (clone.S:84)
> ==19065== by 0x55E893F: ??? (allocatestack.c:743)
> ==19065== by 0x676D90F: ???
> ==19065== Other segment end (thread 2)
> ==19065== at 0x58ACEB7: sched_yield (in /lib/libc-2.10.1.so)
> ==19065== by 0x400A60: threadEntry(void*) (threads.cpp:13)
> ==19065== by 0x4C32870: vgDrd_thread_wrapper (drd_pthread_intercepts.c:272)
> ==19065== by 0x55E8A03: start_thread (pthread_create.c:300)
> ==19065== by 0x58DD80C: clone (clone.S:112)
> ==19065==
> ==19065==
> ==19065== For counts of detected and suppressed errors, rerun with: -v
> ==19065== ERROR SUMMARY: 54 errors from 6 contexts (suppressed: 205 from 142)
>
> Are all the race conditions in I/O code in libstdc++ bening?
>
> If so, are there more things that I should initialize in my app before
> I start creating threads and/or should I be looking into creating
> suppression patterns for drd? Has anyone created them before? Why are
> they not enabled by default in drd?
>
> If not... What should I be reading,doing? Thank you in advance.
>
> Jorge
>
I found the following bug-report against gcc:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40518
It seems that the problem is fixed in gcc 4.5. Until it is released, I
added code to my application to not clear empty strings, and it seems
to solve all the these problems. Thank you very much.
Jorge
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users