When using iostreams with pthreads, a deadlock occurs. One thread may
write to a stream
just fine, but as soon as a second thread attempts to write to a stream, it
blocks on a
pthread mutex. I have narrowed it down to the insertion of an endl into an
ostream. As long
as an endl is not inserted, both threads can write to the stream.
Here is some sample code:
void* threadMain(void* data)
cout << "Thread" << endl;
cout << "Creating thread" << endl;
pthread_create(&thread, NULL, threadMain, NULL);
This problem did not occur with older versions of libstdc++.
assigned to jakub
Please bump the priority of this bug to "High"- it breaks all C++ programs that
and iostream. This includes some of our production applications that we would
be able to compile on RedHat 7 (cross compilation on RedHat 6.1 and 6.2, running
on RedHat 7.0
seems to work).
Fixed in CVS and in the currently building gcc-2.96-60 which should appear
in rawhide soon. There will be a gcc errata after a few more bugs are killed.
Thanks for the report.
*** Bug 20934 has been marked as a duplicate of this bug. ***
*** Bug 21108 has been marked as a duplicate of this bug. ***