From: <na...@uk...> - 2001-02-26 21:25:35
|
Hi, The following program (I am told) runs fine on Solaris and Linux. If compiled with IBM VisualAge for C++ v5 is works too on AIX 4.3.3! But with GNU gcc/g++/C++ it fails to complete most of the time. It uses pthreads and lots of C++ new/malloc calls. My customer regards this as a major weakness in AIX because they are heavily commited to GNU C++ for their core application and this bug will stop them buying IBM pSeries machines. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #include <pthread.h> #include <stdio.h> #include <strings.h> #include <unistd.h> #define MAX_THREADS 100 #define ITERATIONS 3 #define SLEEPTIME 3 void *ThreadFunction(void *In) { int i, j; int val =(int) (int*) (In); for (i = 0; i < ITERATIONS; i ++) { char *hello = NULL; for (j = 1; j <= 1000; j ++) { char *newhello = new char[j + 1]; if (hello) { strcpy(newhello, hello); delete [ ] hello; } else newhello[0] = 0; char *newa = new char[2]; strcpy(newa, "A"); strcat(newhello, newa); delete [ ] newa; hello = newhello; } //printf("%s - %d\n", hello, val); if (hello) delete [ ] hello; sleep(SLEEPTIME); } printf("%d\n", val); return In; } main() { int i; int ret; pthread_t hThread[100]; pthread_attr_t attr; pthread_attr_init (&attr); pthread_attr_setscope (&attr, PTHREAD_SCOPE_PROCESS); printf("Starting\n"); for (i = 0; i < MAX_THREADS; i ++) { ret = pthread_create(&hThread[i], &attr, ThreadFunction, (void*)i); if (ret != 0) { printf("Could not create main thread : UNIX error %d\n", ret); return (-1); } } for (i = 0; i < MAX_THREADS; i ++) { pthread_join(hThread[i], NULL); } return 1; } +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ The idebug debugger tells it crashes in pthread_mutexinit and a source code file called new2.cc - Eh!! thanks Nigel Griffiths IBM Technical Support (RS/6000) UK - e-mail: na...@uk... Performance, Sizing, Benchmarks, RDBMS-Oracle Phone: +44 (0)208-818-4619 (x364619) Mobex: 278698 IBM Internal Web: w3.aixncc.uk.ibm.com for tools like "nmon" and PalmPilot Quick Pricer |