This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gcc 2.95.2/AIX are exceptions thread safe?


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;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]