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

             Bug #: 50703
           Summary: std::stringstream not thread-safe
    Classification: Unclassified
           Product: gcc
           Version: 4.2.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: hoenle2...@kayser-threde.com


Our multi-threaded software (running on the SPARC compatible LEON3 processor
for space applications under the RTEMS 4.9.4 operating system) always locks up
at the same location outside the application software in libstdc++. See
attached debugger screenshot. The error arises between several minutes and
several hours of operation.

We were able to reproduce the problem with GCC/libstdc++ 4.2.4 and with 4.3.2.
We haven't tested newer versions.

The error apparently happens when the GNU library function __atomic_add() in
atomicity.cc is called very often, probably when being called from different
threads.
It could also be possibe that the error is not located in atomicity.cc but
already in its caller std::stringstream (in basic_ios.h).

We are pretty sure the application software can't do anything wrong at this
time as just the std::stringstream constructor is being called for an object on
the stack. See attached debugger screenshot.

We fixed the problem by replacing "std::stringstream" with our own class that
uses "printf" internally. Since then the application software never again
locked up.

Reply via email to