This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
STL + pthreads on AIX4.3.2 causes SEGV (gcc-2.95.1)
- To: gcc at gcc dot gnu dot org
- Subject: STL + pthreads on AIX4.3.2 causes SEGV (gcc-2.95.1)
- From: Stuart Jarriel <sjarriel at motive dot com>
- Date: Thu, 20 Jan 2000 11:13:00 -0600
Attached is a small test program and Makefile that shows the problem.
Ive not been
able to decouple STL & pthreads and still reproduce the problem. I
suspect the
problem is an interaction between the STL object allocation and AIX
pthreads.
The problem shows up as a SEGV when a function tries to return. The
usual pattern
is attempting to stw when the target address register has value that is
wrong (outside
the process heap space).
All that seems to be required to cause the error is multiple threads
must be running
and each thread must allocate an STL object.
stuart
Crpt.cpp
all : Crpt
Crpt : Crpt.cpp
c++ -D_THREAD_SAFE -g -mthreads -I. $< -o $@ -lpthread
clean :
rm Crpt
Description of the Problem
--------------------------
Apparant stack corruption. With the proper combination of elements
(described later) the stack for a leaf procedure is corrupted such
that it cannot return to its caller.
Required Elements
-----------------
There must be more than 1 thread running.
Each thread must call a function multiple times.
The function must declare a STL object as a local variable,
allocate one, and then free it.
Number of Threads & Loops
-------------------------
The fault requires a large number of loops and > 1 threads.
The default values here cause the error 90% of the time
on my system. Decreasing them reduces the frequency of
the error. I see the error with as few as 2 threads and
20000 loops, but its infrequent. 2 threads and 200K loops
shows the error every time. Ive never seen the problem
with a single thread, or with a small # of loops. I suspect
the problem is related to seeing a thread run/yield/run, and
the large loop count just allocates enough time to let the
running thread timeslice out.
Affected Platforms
------------------
This code works correctly on Solaris 2.[67] with egcs1.1.1, egcs1.1.2
and gcc-2.95.1. It does not work on HPUX11 with egcs1.1.1 (others were
not tried). And it does not work on AIX 4.3.2 with egcs1.1.2 or gcc-2.95.1.