https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90964
Bug ID: 90964 Summary: SJLJ: Backtrace stopped: previous frame inner to this frame (corrupt stack?) Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ocroquette at free dot fr Target Milestone: --- On Windows with the SJLJ exception handling, the backtrace doesn't work in GDB as soon a method enters a try/catch block, instead GDB reports: Backtrace stopped: previous frame inner to this frame (corrupt stack?) The problem can be easily reproduced with any SJLJ Mingw-w64 toolchain. The problem doesn't occur with SEH exception handling. It is not clear if the problem is in GCC, GDB or MinGW-w64. I don't know how to find out, hopefully someone competent can tell if it is a GCC bug or not. main.cpp: #include <stdexcept> void dummy() { volatile int i = 0; } bool expectTrue( bool value ) { dummy(); if ( !static_cast<bool>( value ) ) { throw std::runtime_error("value failed"); } dummy(); return value; } int main( int argc, char** argv ) { dummy(); expectTrue( true ); dummy(); } gcc --version gcc (x86_64-posix-sjlj-rev0, Built by MinGW-W64 project) 7.2.0 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. g++ -g -O0 main.cpp -o main gdb ./main GNU gdb (GDB) 8.0.1 ... (gdb) break dummy Breakpoint 1 at 0x401578: file main.cpp, line 7. (gdb) run ... Thread 1 hit Breakpoint 1, dummy () at main.cpp:7 7 volatile int i = 0; (gdb) backtrace #0 dummy () at main.cpp:7 #1 0x0000000000401728 in main (argc=1, argv=0x25d1d20) at main.cpp:28 (gdb) continue Continuing. Thread 1 hit Breakpoint 1, dummy () at main.cpp:7 7 volatile int i = 0; (gdb) backtrace #0 dummy () at main.cpp:7 #1 0x0000000000401626 in expectTrue (value=true) at main.cpp:13 #2 0x0000000000000000 in ?? () Backtrace stopped: previous frame inner to this frame (corrupt stack?) (gdb) continue Continuing. Thread 1 hit Breakpoint 1, dummy () at main.cpp:7 7 volatile int i = 0; (gdb) backtrace #0 dummy () at main.cpp:7 #1 0x000000000040167b in expectTrue (value=true) at main.cpp:20 #2 0x0000000000000000 in ?? () Backtrace stopped: previous frame inner to this frame (corrupt stack?) (gdb) continue Continuing. Thread 1 hit Breakpoint 1, dummy () at main.cpp:7 7 volatile int i = 0; (gdb) backtrace #0 dummy () at main.cpp:7 #1 0x0000000000401737 in main (argc=1, argv=0x25d1d20) at main.cpp:30 (gdb) continue Continuing. [Thread 5844.0x1750 exited with code 0] [Thread 5844.0x1320 exited with code 0] [Thread 5844.0x2334 exited with code 0] [Inferior 1 (process 5844) exited normally] (gdb)