Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* gdb built from gcc 4.6.1 has some crash problem
@ 2011-10-11 13:38 asmwarrior
  2011-10-11 22:51 ` Chris Sutcliffe
  0 siblings, 1 reply; 6+ messages in thread
From: asmwarrior @ 2011-10-11 13:38 UTC (permalink / raw)
  To: gdb

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-10-21  3:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-11 13:38 gdb built from gcc 4.6.1 has some crash problem asmwarrior
2011-10-11 22:51 ` Chris Sutcliffe
     [not found]   ` <CA+BR0wynvgwW3btKZ+ftjjJ63htVHeScG97c3ovxNgpGrGvmOw@mail.gmail.com>
2011-10-12  0:42     ` Chris Sutcliffe
2011-10-12  1:01       ` xunxun
2011-10-21  3:04         ` Asmwarrior
2011-10-21  9:03           ` xunxun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox