http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50664
Bug #: 50664 Summary: GDB rebuilt by i686-w64-mingw32-gcc4.6.2's "-Os" crahed when debuging, but "-O2" is OK. Classification: Unclassified Product: gcc Version: 4.6.2 Status: UNCONFIRMED Severity: critical Priority: P3 Component: other AssignedTo: unassig...@gcc.gnu.org ReportedBy: xunxun1...@gmail.com I don't know which section this issue can be reported in. I rebuilt the latest gcc4.6 branch on Win7 and I found a weird probem. When I use the editon to build gdb with "-Os", it won't list source code, and if you input list twice, gdb will crash. The debug log: -------------------------------------------------------------- GNU gdb (GDB) 7.3.1.20110921-cvs Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <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 "i686-w64-mingw32". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from E:\MyPack\MinGW\bin/gdb-1.exe...done. (gdb) run Starting program: E:\MyPack\MinGW\bin/gdb-1.exe [New Thread 2212.0x1ba8] GNU gdb (pcx32) 7.3.1 Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <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 "i686-w64-mingw32". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. (gdb) file a.exe Reading symbols from e:\t\temp\a.exe...done. (gdb) l (gdb) No source file named main. l [New Thread 2212.0xe34] [New Thread 2212.0x654] Program received signal SIGSEGV, Segmentation fault. 0x0041ad8b in exceptions_state_mc (action=CATCH_THROWING) at exceptions.c:126 126 switch (current_catcher->state) (gdb) bt #0 0x0041ad8b in exceptions_state_mc (action=CATCH_THROWING) at exceptions.c:126 #1 0x0041ad0d in throw_exception (exception=...) at exceptions.c:240 #2 0x0041ae68 in exceptions_state_mc (action=<optimized out>) at exceptions.c:191 #3 0x0041b1d4 in catch_errors (func=0x40181e <captured_main>, func_args=0x28fe90, errstring=0x614070 "", mask=6) at exceptions.c:519 #4 0x0040262c in gdb_main (args=0x28fe90) at ./main.c:949 #5 0x00608ef0 in main (argc=1, argv=0x3f2fc0) at gdb.c:35 (gdb) bt 30 #0 0x0041ad8b in exceptions_state_mc (action=CATCH_THROWING) at exceptions.c:126 #1 0x0041ad0d in throw_exception (exception=...) at exceptions.c:240 #2 0x0041ae68 in exceptions_state_mc (action=<optimized out>) at exceptions.c:191 #3 0x0041b1d4 in catch_errors (func=0x40181e <captured_main>, func_args=0x28fe90, errstring=0x614070 "", mask=6) at exceptions.c:519 #4 0x0040262c in gdb_main (args=0x28fe90) at ./main.c:949 #5 0x00608ef0 in main (argc=1, argv=0x3f2fc0) at gdb.c:35 (gdb) q A debugging session is active. Inferior 1 [process 2212] will be killed. Quit anyway? (y or n) ---------------------------------------------------------------------------- But if I replace "-Os" with "-O2" to rebuild again, gdb will work ok. And gcc4.6.1 release haven't the issue. I don't know why. So it's gcc's -Os bug? But I only found the issue when I built gdb, other projects with "-Os" work well.