gcc and v3 (or other threadsafe stdlib) on Solaris
Fri Feb 9 09:32:00 GMT 2001
I have developed a multi-threaded C++ application which uses
STL for strings and containers (I chose STL because I need
the portability). When I use the current release of gcc
(2.95.2) to build it on Solaris 2.6, I have problems with
intermittent crashes, usually taking many hours or even days
to occur. Could there be problems in libstdc++ version 2.10
which could result in these symptoms?
- intermittent crashes, often after many hours or even
- crashes always related to heap corruption, and usually
appear in one or another destructor.
- probability of crashing increases with the number of
- never crash with a single thread.
- probability increases with the number of cpus in the
system, but still occurs with a single cpu.
I use a small subset of STL: map, multimap, set, vector,
string, and deque. I can get the crash to occur with a
subset of my code which uses only vector and string. All
accesses to containers shared between threads are
synchronized via mutexes, and in fact I can get crashes to
occur even when there is no data shared between threads.
The reason I ask is this: if the solution is to replace
libstdc++ with libstdc++-v3, there is a whole set of issues
and problems that come up, so I want to be sure there is a
good chance that it will solve the problems I am having with
crashes. In particular, it is no longer possible to use a
released version of gcc with the latest v3 library, and I
don't feel comfortable using a gcc snapshot for development.
I tried to build a gcc snapshot just to see if it would help
( ftp://ftp.freesoftware.com/pub/sourceware/gcc/snapshots/2001-01-08/ ),
but I am currently not able to compile it for Solaris. At
it says that binutils 2.9.1 should not be used on Solaris,
because of known bugs, and that you should use Sun's ld and
as as a workaround. It then goes on to say that libstdc++
doesn't work with Sun's as!
Some of the archived messages on this list refer to problems
in libstdc++-v2 with the string implementation not being
threadsafe (using SGI's definition of threadsafe). Is it
possible to just replace the basic_string implementation in
v2 with one that is threadsafe (say, SGI's version), and is
that a reasonable thing to do? What was wrong with SGI's
basic_string which resulted in its being replaced in the
first place? Is this likely to solve my problems with
crashes or are there other problems with v2 thread safety?
More information about the Libstdc++