public inbox for gdb@sourceware.org
 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

* Re: gdb built from gcc 4.6.1 has some crash problem
  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>
  0 siblings, 1 reply; 6+ messages in thread
From: Chris Sutcliffe @ 2011-10-11 22:51 UTC (permalink / raw)
  To: gdb

On 11 October 2011 09:39, asmwarrior wrote:
> Does this issue happened in Linux also?

FWIW, I've confirmed this behaviour using mingw.org's gcc 4.6.1 to
compile 7.3.1.  I then compiled 7.3.1 using the gcc 4.6.1 that shipped
with Arch Linux and was not able to re-create the issue (I experienced
the 'good' behaviour).  So this issue seems specific to the mingw
target for gcc 4.6.x.

In terms of next steps, is this something that should be brought up on
the gcc mailing list?

Thank you,

Chris

-- 
Chris Sutcliffe
http://emergedesktop.org
http://www.google.com/profiles/ir0nh34d

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

* Re: gdb built from gcc 4.6.1 has some crash problem
       [not found]   ` <CA+BR0wynvgwW3btKZ+ftjjJ63htVHeScG97c3ovxNgpGrGvmOw@mail.gmail.com>
@ 2011-10-12  0:42     ` Chris Sutcliffe
  2011-10-12  1:01       ` xunxun
  0 siblings, 1 reply; 6+ messages in thread
From: Chris Sutcliffe @ 2011-10-12  0:42 UTC (permalink / raw)
  To: gdb

On 11/10/2011 7:46 PM, xunxun wrote:
>
> On Wed, Oct 12, 2011 at 6:51 AM, Chris Sutcliffe <ir0nh34d@gmail.com 
> <mailto:ir0nh34d@gmail.com>> wrote:
>
>     On 11 October 2011 09:39, asmwarrior wrote:
>     > Does this issue happened in Linux also?
>
>     FWIW, I've confirmed this behaviour using mingw.org
>     <http://mingw.org>'s gcc 4.6.1 to
>     compile 7.3.1.  I then compiled 7.3.1 using the gcc 4.6.1 that shipped
>     with Arch Linux and was not able to re-create the issue (I experienced
>     the 'good' behaviour).  So this issue seems specific to the mingw
>     target for gcc 4.6.x.
>
> Your ArchLinux is 32bit or 64bit? Gcc is 32bit or 64bit?

I'm running 32-bit Arch Linux using 32-bit gcc.

Chris

-- 
Chris Sutcliffe
ir0nh34d@gmail.com
http://emergedesktop.org
http://www.google.com/profiles/ir0nh34d

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

* Re: gdb built from gcc 4.6.1 has some crash problem
  2011-10-12  0:42     ` Chris Sutcliffe
@ 2011-10-12  1:01       ` xunxun
  2011-10-21  3:04         ` Asmwarrior
  0 siblings, 1 reply; 6+ messages in thread
From: xunxun @ 2011-10-12  1:01 UTC (permalink / raw)
  To: Chris Sutcliffe; +Cc: gdb, asmwarrior

于 2011/10/12 8:42, Chris Sutcliffe 写道:
>
> I'm running 32-bit Arch Linux using 32-bit gcc.
>
> Chris 

Sorry, my last mail is not delivered successfully.
So I email again:

I can confirm the issue also existed in the MinGW64 gcc4.6.1, but no 
problem on Win7 64bit. Is this only on WinXP?
In addition, latest gcc4.6 branch also has the problem, specially, gdb 
built by latest gcc4.6 branch has an another crash question, I reported 
it to gcc bugzilla: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50664

-- 
Best Regards,
xunxun

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

* Re: gdb built from gcc 4.6.1 has some crash problem
  2011-10-12  1:01       ` xunxun
@ 2011-10-21  3:04         ` Asmwarrior
  2011-10-21  9:03           ` xunxun
  0 siblings, 1 reply; 6+ messages in thread
From: Asmwarrior @ 2011-10-21  3:04 UTC (permalink / raw)
  To: xunxun; +Cc: Chris Sutcliffe, gdb, MinGW Users List

Hi, all. Just for a record.

This reason that gdb crash on WinXP build from gcc 4.6.x can be found here:

http://lists.gnu.org/archive/html/qemu-devel/2011-10/msg02462.html

When building gdb with "-omit-frame-pointer" disabled, gdb works well.

Also, Kai Tietz supplies a patch to solve this problem. (I'm not sure
how the patch works, does it just disable the -omit-frame-pointer on
I386 for mingw?)


asmwarrior
ollydbg from codeblocks' forum

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

* Re: gdb built from gcc 4.6.1 has some crash problem
  2011-10-21  3:04         ` Asmwarrior
@ 2011-10-21  9:03           ` xunxun
  0 siblings, 0 replies; 6+ messages in thread
From: xunxun @ 2011-10-21  9:03 UTC (permalink / raw)
  To: Asmwarrior; +Cc: Chris Sutcliffe, gdb, MinGW Users List, Kai Tietz

于 2011/10/21 8:41, Asmwarrior 写道:
> Hi, all. Just for a record.
>
> This reason that gdb crash on WinXP build from gcc 4.6.x can be found here:
>
> http://lists.gnu.org/archive/html/qemu-devel/2011-10/msg02462.html
>
> When building gdb with "-omit-frame-pointer" disabled, gdb works well.
It's strange that -O2 enables "-fomit-frame-pointer", but -Os doesn't. 
Because I build gdb with "-Os" to work well, but gdb will also crash 
when built with "-Os -fomit-frame-pointer".
>
> Also, Kai Tietz supplies a patch to solve this problem. (I'm not sure
> how the patch works, does it just disable the -omit-frame-pointer on
> I386 for mingw?)
This patch can only be used for trunk (4.7), but no gcc4.6 branch. I 
don't know whether there is another better method to solve the issue.
>
>
> asmwarrior
> ollydbg from codeblocks' forum


-- 
Best Regards,
xunxun

^ 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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).