Stack overflow could cause the program to terminate by sending SIGABRT signal. You can detect this with latest gcc compiler(4.2 above) under gdb debugger.
Run the program under gdb and once the program terminates, check call stack(run bt command in gdb) and see your call stack for a call to the function __stack_chk_fail().
The interface __stack_chk_fail() will abort the function that called it with a message that a stack overflow has been detected. The program that called the function shall then exit.
Below is the output you will get when run xxxxxx program under gdb.
/Developer/usr/bin/gdb xxxxxx
(gdb) run
Program received signal SIGABRT, Aborted.
0x92fb9a6a in __pthread_kill ()
(gdb) bt
#0 0x92fb9a6a in __pthread_kill ()
#1 0x91d60acf in pthread_kill ()
#2 0x91d975ff in __abort ()
#3 0x91d98582 in __stack_chk_fail ()
#4 0x0019f2fc in CLocalSector::CreateSPIBuffer ()
#5 0x001a042c in CLocalSector::ReadStatus ()
#6 0x001966ee in CDM::readJobStatus ()
#7 0x00004402 in RunJobs ()
#8 0x0000c7c0 in main ()
References:
1) http://refspecs.linux-foundation.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/libc---stack-chk-fail-1.html
2) http://wiki.osdev.org/GCC_Stack_Smashing_Protector
Run the program under gdb and once the program terminates, check call stack(run bt command in gdb) and see your call stack for a call to the function __stack_chk_fail().
The interface __stack_chk_fail() will abort the function that called it with a message that a stack overflow has been detected. The program that called the function shall then exit.
Below is the output you will get when run xxxxxx program under gdb.
/Developer/usr/bin/gdb xxxxxx
(gdb) run
Program received signal SIGABRT, Aborted.
0x92fb9a6a in __pthread_kill ()
(gdb) bt
#0 0x92fb9a6a in __pthread_kill ()
#1 0x91d60acf in pthread_kill ()
#2 0x91d975ff in __abort ()
#3 0x91d98582 in __stack_chk_fail ()
#4 0x0019f2fc in CLocalSector::CreateSPIBuffer ()
#5 0x001a042c in CLocalSector::ReadStatus ()
#6 0x001966ee in CDM::readJobStatus ()
#7 0x00004402 in RunJobs ()
#8 0x0000c7c0 in main ()
References:
1) http://refspecs.linux-foundation.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/libc---stack-chk-fail-1.html
2) http://wiki.osdev.org/GCC_Stack_Smashing_Protector
No comments:
Post a Comment