This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gdb built from gcc 4.6.1 has some crash problem


I found a complex problem that I hope that you gdb developers can give some help.

I'm regularly building gdb cvs under mingw. I found that gdb build from gcc 4.6.1 with O2 optimization does not works correctly.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Here are my build setup: (all tested under Windows XP)

[compiler ] , [gdb build optimization] , [gdb result]

1, tdm gcc 4.6.1 sjlj , -O2 , bad
2, tdm gcc 4.6.1 sjlj , -O0 , good
3, tdm gcc 4.5.2 sjlj , -O2 , good

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Here is the test program I use(I insert an inline break-point in the source code)

#include <stdio.h>
int main()
{
    int a = 0;
    printf("%d",a);
    a++;
    a=3;
    asm("int $3");
    ;
    printf("%d",a);
}
I build it with the command like:
gcc -o app.exe -O0 -g app.c
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The test of the bad result:

E:\op\test>gdb_tdm46o2 app.exe
GNU gdb (GDB) 7.3.50.20111009-cvs
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/> <http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from e:\op\test\app.exe...done.
(gdb) r
Starting program: e:\op\test\app.exe
[New Thread 2464.0xe8]
0
Program received signal SIGTRAP, Trace/breakpoint trap.
main () at e:\op\test\app.c:10
10              printf("%d",a);
(gdb) p a
$1 = 3
(gdb) p b

Then, gdb crashed on this command, it will pop up a Windows error message, then gdb exit abnormally.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
the good result look like:
(both the official mingw gdb7.2/7.3, the gdb tdm452 -O2 build, the gdb tdm 461 -O0 build have the same good results)

E:\op\test>gdb_tdm46o0 app.exe
GNU gdb (GDB) 7.3.50.20111009-cvs
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/> <http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from e:\op\test\app.exe...done.
(gdb) r
Starting program: e:\op\test\app.exe
[New Thread 2684.0xe34]
0
Program received signal SIGTRAP, Trace/breakpoint trap.
main () at e:\op\test\app.c:10
10              printf("%d",a);
(gdb) p a
$1 = 3
(gdb) p b
No symbol "b" in current context.
(gdb) c
Continuing.
3[Inferior 1 (process 2684) exited with code 01]
(gdb) q

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Finally, this only happened on the gdb build from tdm 4.6.1 with -O2, and under WinXP.
My friend xunxun has also test many gdb build from other gcc 4.6.1(like the mingw offcial gcc 4.6 or xunxun's own gcc 4.6), they all have the same result as mine.
But, gdb build from tdm 4.6.1 -O2 works OK under Win7.

I try to catch the error, by running gdb under gdb, but I can't catch the backtrack, see the log below:
E:\op\test>gdb gdb_tdm46o2
GNU gdb (GDB) 7.2
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/> <http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from E:\op\test/gdb_tdm46o2.exe...
done.
(gdb) r
Starting program: E:\op\test/gdb_tdm46o2.exe
[New Thread 3412.0x8a0]
GNU gdb (GDB) 7.3.50.20111009-cvs
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/> <http://www.gnu.org/software/gdb/bugs/>.
(gdb) [New Thread 3412.0xf7c]
[New Thread 3412.0xcd4]
file app.exe
Reading symbols from e:\op\test\app.exe...done.
(gdb) r
Starting program: e:\op\test\app.exe
[New Thread 3588.0xbf4]
0
Program received signal SIGTRAP, Trace/breakpoint trap.
main () at e:\op\test\app.c:10
10              printf("%d",a);
(gdb) p a
$1 = 3
(gdb) p b

Program received signal SIGSEGV, Segmentation fault.
0x77c3554a in msvcrt!_abnormal_termination ()
   from C:\WINDOWS\system32\msvcrt.dll
(gdb) bt
#0  0x77c3554a in msvcrt!_abnormal_termination ()
   from C:\WINDOWS\system32\msvcrt.dll
#1  0x77c39bc6 in strerror () from C:\WINDOWS\system32\msvcrt.dll
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
It always report some corrupt stack problem, and I failed to see the crashed gdb's back-trace.


I hope you gdb developers can give me some directions, maybe, the gcc 4.6.x has some optimization error? but the strange thing is it only crashed under Windows XP, it works OK under Win 7.


Does this issue happened in Linux also?

thank you !

asmwarrior
ollydbg from codeblocks' forum


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]