From mboxrd@z Thu Jan 1 00:00:00 1970 From: rob.renfrew@epiphany.com To: gcc-gnats@gcc.gnu.org Subject: libstdc++/2932: new operator segfaults for arrays using pthreads on hpux Date: Thu, 24 May 2001 16:56:00 -0000 Message-id: <20010524234836.31400.qmail@sourceware.cygnus.com> X-SW-Source: 2001-05/msg00735.html List-Id: >Number: 2932 >Category: libstdc++ >Synopsis: new operator segfaults for arrays using pthreads on hpux >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Thu May 24 16:56:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: rob.renfrew@epiphany.com >Release: gcc version 2.95.2 19991024 (release) >Organization: >Environment: HP-UX 11 >Description: spawning many threads which each allocate new arrays will cause a segmentation fault on HPUX11. error does not occur using new to allocate non-arrays, or with malloc(). >How-To-Repeat: build as: gcc -o RTT RTT.cpp -lpthread run ./RTT >Fix: >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/plain; name="RTT.cpp" Content-Disposition: inline; filename="RTT.cpp" #include #include #include #define NUM_THREADS 100 #define NUM_LOOPS 100 #define RT_SIZE 100 //typedef unsigned short Rtype; typedef char Rtype; void* memory_test(void *arg) { for (int i = 0; i < NUM_LOOPS; i++) { Rtype* rt = new Rtype[RT_SIZE]; delete rt; } } int main(int argc, char **argv) { int status; pthread_t *threads; threads = new pthread_t[NUM_THREADS]; for (int i = 0; i < NUM_THREADS; i++) { status = pthread_create(&(threads[i]), NULL, memory_test, NULL); if (status != 0) { fprintf(stderr, "failed: pthread_create: %d\n", i); exit(-1); } } void *trash; for (int i = 0; i < NUM_THREADS; i++) { status = pthread_join(threads[i], &trash); if (status != 0) { fprintf(stderr, "failed: pthread_join: %d\n", i); exit(-1); } } return 0; }