This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
gcc 2.95.2/AIX are exceptions thread safe?
- To: gcc bug list <gcc-bugs at gcc dot gnu dot org>
- Subject: gcc 2.95.2/AIX are exceptions thread safe?
- From: Martin Sebor <sebor at roguewave dot com>
- Date: Mon, 12 Mar 2001 12:30:33 -0700
- CC: Michael Yoder <yoder at roguewave dot com>
- Organization: Rogue Wave Software, Inc.
Hi,
The trivial testcase below (intermittently) segfaults at runtime when
compiled with gcc 2.95.2 on AIX 4.3. Are there any known issues with
exceptions and dynamic memory allocation?
We can reproduce the crashes even if we replace the calls to operator
new and delete with calls to trivial functions like this:
struct bad_alloc { };
void* our_new (size_t n) throw (bad_alloc)
{
return malloc (n);
}
void our_delete (void *p) throw ()
{
free (p);
}
Thanks
Martin
#include <pthread.h>
void* routine(void *)
{
char * ret;
for (int i = 0; i < 3500; ++i) {
ret = new char[21];
delete [] ret;
}
return NULL;
}
int main() {
const int NUMTHR = 40;
pthread_t threadHandles[NUMTHR] = {0};
for (int i = 0; i < NUMTHR; i++)
pthread_create(threadHandles+i, 0, routine, NULL);
for (int i = 0; i < NUMTHR; i++)
pthread_join(threadHandles[i],0);
return 0;
}