my program compiled by GCC crashed

王克驰 wangkc.cs@gmail.com
Fri Dec 11 07:25:00 GMT 2009


Hi gcc-help,

Our system crashed which was compiled by GCC. While, we can not say
that GCC compiler is the root cause.

But the strange thing is that I created a sample test code and
compiled it with GCC. It worked fine when I chose O0 as the
optimization level but it crashed when I chose other optimization
levels.

It did not crashed when I used SUN CC compiler no matter which
optimization level I chose.

Below please find my test code and Makefile. The code is very simple
and the only thing I did is let it link to a library
/usr/lib/64/libicuio.so.3.

Thanks,
James

BTW: change -m64 to -m32 could also let the core dump go away.

GCC version: 4.0.1
Target: i386-pc-solaris2.10
Thread model: posix

*******************************main.cc***************************************

#include <iostream>
using namespace std;

void* th_test(void* arg)
{
    cout << "this is a thread: " << pthread_self() << endl;
    pthread_exit(0);
}

int main (int argc, char* argv[])
{
    pthread_attr_t thread_attr;
    pthread_t thread;
    pthread_attr_init(&thread_attr);
    pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED);
    pthread_create(&thread, &thread_attr, th_test, NULL);

    sleep(1);
    cout << "this is main: " << pthread_self() << endl;
}

*****************************Makefile*******************************************
all : test

CC = g++ -g -fPIC -O3 -ggdb3 -m64 -Wno-deprecated

.cc.o:
	$(CC) -c -o $@ $< -I .

test : main.o
	$(CC) main.o  -o test -licutu

clean :
	rm -rf *.o  test core


******************************End************************************************



More information about the Gcc-help mailing list