Yet another exceptions bug
Iggy Veresov
iggy@homepage.ru
Sun Apr 2 09:34:00 GMT 2000
A segmentation fault occures when couple of threads are using
exceptions.
Probably it's a race condition in exception handling code.
The problem exists both with GCC 2.95.2 and with current GCC 2.96
20000327.
Optimization level doesn't matter.
OS: RedHat 5.1, linux 2.2.14, glibc 2.1.2, LinuxThreads library that
comes with glibc.
The following code demonstrates the problem:
=======================
// x.cc
// g++ -O3 -lpthread -o x x.cc
#include <pthread.h>
#include <unistd.h>
pthread_t t1,t2;
class X { };
void *thread_1 (void *) {
while (1) {
try {
throw X ();
}
catch (...) { }
}
}
void *thread_2 (void *) {
while (1) {
try {
throw X ();
}
catch (...) { }
}
}
int
main (void)
{
pthread_create (&t1, NULL, thread_1, NULL);
pthread_create (&t2, NULL, thread_2, NULL);
while (1) sleep (1); // wait for a crash..
}
==========
--
/ig,
mailto:iggy@homepage.ru ,
http://www.homepage.ru/~iggy
More information about the Gcc-bugs
mailing list