From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 469 invoked by alias); 11 Oct 2011 13:38:22 -0000 Received: (qmail 447 invoked by uid 22791); 11 Oct 2011 13:38:19 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_DB,TW_JL,TW_NX,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-pz0-f49.google.com (HELO mail-pz0-f49.google.com) (209.85.210.49) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 11 Oct 2011 13:37:59 +0000 Received: by pzk34 with SMTP id 34so19890893pzk.8 for ; Tue, 11 Oct 2011 06:37:59 -0700 (PDT) Received: by 10.68.20.226 with SMTP id q2mr45073522pbe.115.1318340278824; Tue, 11 Oct 2011 06:37:58 -0700 (PDT) Received: from [192.168.1.102] ([115.195.157.164]) by mx.google.com with ESMTPS id ji3sm79381372pbc.2.2011.10.11.06.37.09 (version=SSLv3 cipher=OTHER); Tue, 11 Oct 2011 06:37:57 -0700 (PDT) Message-ID: <4E94471F.3010609@gmail.com> Date: Tue, 11 Oct 2011 13:38:00 -0000 From: asmwarrior User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 To: gdb@sourceware.org Subject: gdb built from gcc 4.6.1 has some crash problem Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2011-10/txt/msg00056.txt.bz2 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 int main() { int a =3D 0; printf("%d",a); a++; a=3D3; 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 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: ... 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 =3D 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 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: ... 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 =3D 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 u= nder 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 res= ult 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 b= acktrack, 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 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: ... 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 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: . (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 =3D 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 crashe= d 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 unde= r Windows XP, it works OK under Win 7. Does this issue happened in Linux also? thank you ! asmwarrior ollydbg from codeblocks' forum