When debugging i notices, that certain functions who throw are unable to show a backtrace. Gdb shows an like: Backtrace stopped: previous frame inner to this frame (corrupt stack?)
All posix sjlj gcc versions are affected except seh.
Here are the steps to reproduce:
λ cat main.cpp
#include<stdexcept>
void
dummy()
{
volatileint 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
Copyright (C) 2017 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 "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./main...done.
(gdb) break dummy
Breakpoint 1 at 0x401578: file main.cpp, line 7.
(gdb) run
Starting program: C:\Users\mdr\Entwicklung\stackTest\main.exe
[New Thread 5844.0x1d58]
[New Thread 5844.0x1320]
[New Thread 5844.0x2334]
[New Thread 5844.0x1750]
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)
When debugging i notices, that certain functions who throw are unable to show a backtrace. Gdb shows an like: Backtrace stopped: previous frame inner to this frame (corrupt stack?) All posix sjlj gcc versions are affected except seh. Here are the steps to reproduce:
λ cat main.cpp
λ gcc --version
λ g++ -g -O0 main.cpp -o mainλ gdb ./main