In a multithreaded application if I use a std::string in the thread I get a 
coredump, but the coredump doesn't occur every time. The OS is Compaq Tru64 
UNIX V5.1A.

BEGIN CODE

#include <pthread.h>
#include <unistd.h>
#include <iostream>
#include <exception>

#define NUMBER_OF_THREADS 1000

void * thread(void *);

int main()
{
        for (int t = 0; t < 20; ++t)
        {
                pthread_t thr[NUMBER_OF_THREADS];
                for (int i = 0; i < NUMBER_OF_THREADS; ++i)
                {
                        if (pthread_create(&thr[i], 0, &thread, 0) != 0)
                                std::cerr << "Error creating the thread " << t 
<< " - " << i << std::endl;
                }

                for (int i = 0; i < NUMBER_OF_THREADS; ++i)
                {
                        if (pthread_join(thr[i], NULL) != 0)
                                std::cerr << "Error joining the thread " << t 
<< " - " << i << std::endl;
                }
        }
}

void * thread(void *)
{
        const std::string home("123456789 123456789 123456789 123456789 \n");
        return 0;
}

END CODE

BEGIN COMPILATION COMMAND

[EMAIL PROTECTED] pau $ g++ -v -save-temps -pthread -o x main.cc -
lpthread        
Reading specs from /opt/TWWfsw/gcc302/lib/gcc-lib/alpha-dec-osf5.1/3.0.2/specs
Configured with: ../configure --enable-nls --with-included-gettext --enable-
shared --enable-libgcj --enable-threads --prefix=/opt/TWWfsw/gcc302 --with-
local-prefix=/opt/TWWfsw/gcc302
Thread model: single
gcc version 3.0.2
 /opt/TWWfsw/gcc302/lib/gcc-lib/alpha-dec-osf5.1/3.0.2/cpp0 -lang-c++ -
D__GNUG__=3 -D__GXX_DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -v -
iprefix /opt/TWWfsw/bin/../lib/gcc-lib/alpha-dec-osf5.1/3.0.2/ -D__GNUC__=3 -
D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=2 -Dunix -D__osf__ -D_LONGLONG -
DSYSTYPE_BSD -D_SYSTYPE_BSD -D__unix__ -D__osf__ -D_LONGLONG -
D__SYSTYPE_BSD__ -D_SYSTYPE_BSD -D__unix -D__SYSTYPE_BSD -Asystem=unix -
Asystem=xpg4 -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D__LANGUAGE_C_PLUS_PLUS__ -
D__LANGUAGE_C_PLUS_PLUS -D__cplusplus -Acpu=alpha -Amachine=alpha -D__alpha -
D__alpha__ -D__alpha_ev4__ -Acpu=ev4 -D_REENTRANT -D__X_FLOAT main.cc main.ii
GNU CPP version 3.0.2 (cpplib)
ignoring nonexistent directory "/opt/TWWfsw/lib/gcc-lib/alpha-dec-
osf5.1/3.0.2/../../../../include/g++-v3"
ignoring nonexistent directory "/opt/TWWfsw/lib/gcc-lib/alpha-dec-
osf5.1/3.0.2/../../../../include/g++-v3/alpha-dec-osf5.1"
ignoring nonexistent directory "/opt/TWWfsw/lib/gcc-lib/alpha-dec-
osf5.1/3.0.2/../../../../include/g++-v3/backward"
ignoring nonexistent directory "/opt/TWWfsw/lib/gcc-lib/alpha-dec-
osf5.1/3.0.2/include"
ignoring nonexistent directory "/opt/TWWfsw/lib/gcc-lib/alpha-dec-
osf5.1/3.0.2/../../../../alpha-dec-osf5.1/include"
ignoring nonexistent directory "/opt/TWWfsw/gcc302/alpha-dec-osf5.1/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/TWWfsw/gcc302/include/g++-v3
 /opt/TWWfsw/gcc302/include/g++-v3/alpha-dec-osf5.1
 /opt/TWWfsw/gcc302/include/g++-v3/backward
 /opt/TWWfsw/gcc302/include
 /opt/TWWfsw/gcc302/lib/gcc-lib/alpha-dec-osf5.1/3.0.2/include
 /usr/include
End of search list.
 /opt/TWWfsw/gcc302/lib/gcc-lib/alpha-dec-osf5.1/3.0.2/cc1plus -fpreprocessed 
main.ii -quiet -dumpbase main.cc -version -o main.s
GNU CPP version 3.0.2 (cpplib)
GNU C++ version 3.0.2 (alpha-dec-osf5.1)
        compiled by GNU C version 3.0.2.
 as -g -oldas -c -nocpp -O0 -o main.o main.s
 /opt/TWWfsw/gcc302/lib/gcc-lib/alpha-dec-osf5.1/3.0.2/mips-tfile -v -I 
main.o~ -o main.o main.s
mips-tfile version 3.0.2
 /opt/TWWfsw/gcc302/lib/gcc-lib/alpha-dec-osf5.1/3.0.2/collect2 -G 8 -O1 -
call_shared -o x /usr/lib/cmplrs/cc/crt0.o -L/opt/TWWfsw/gcc302/lib/gcc-
lib/alpha-dec-osf5.1/3.0.2 -L/usr/lib/cmplrs/cc -L/opt/TWWfsw/gcc302/lib/gcc-
lib/alpha-dec-osf5.1/3.0.2/../../.. main.o -lpthread -lstdc++ -lm -lgcc_s -
lgcc -lpthread -lmach -lexc -lc -lgcc_s -lgcc

END COMPILATION COMMAND

BEGIN RUN

[EMAIL PROTECTED] pau $ ./x
Memory fault(coredump)

END RUN

-- 
           Summary: coredum during thread processing
           Product: gcc
           Version: 3.0.2
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mpinto at brturbo dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18807

Reply via email to