[debug]Command-line: C:\TDM-GCC-32\bin\gdb32.exe -nx -fullname -quiet -args C:/projects/Teemu/Teemu.exe
[debug]Working dir : C:\projects\Teemu
Starting debugger: C:\TDM-GCC-32\bin\gdb32.exe -nx -fullname -quiet -args C:/projects/Teemu/Teemu.exe
done
[debug]> set prompt >>>>>>cb_gdb:
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
[debug]Reading symbols from C:/projects/Teemu/Teemu.exe...
[debug]done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.9.1
[debug]Copyright (C) 2015 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law. Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "mingw32".
[debug]Type "show configuration" for configuration details.
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]Find the GDB manual and other documentation resources online at:
[debug]<http://www.gnu.org/software/gdb/documentation/>.
[debug]For help, type "help".
[debug]Type "apropos word" to search for commands related to "word".
[debug]>>>>>>cb_gdb:
[debug]> set confirm off
Debugger name and version: GNU gdb (GDB) 7.9.1
[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 0
[debug]>>>>>>cb_gdb:
[debug]> set new-console on
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor att
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> source C:\Program Files (x86)\CodeBlocks\share\codeblocks/scripts/stl-views-1.0.3.gdb
[debug]>>>>>>cb_gdb:
[debug]> directory C:/projects/Teemu/
[debug]Source directories searched: C:/projects/Teemu;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: C:\projects\Teemu\Teemu.exe
Child process PID: 6644
[debug][New Thread 6644.0x440]
[debug][New Thread 6644.0x2484]
[debug][New Thread 6644.0x1264]
[debug][New Thread 6644.0x1508]
[debug][New Thread 6644.0x1ba0]
[debug][Thread 6644.0x1ba0 exited with code 0]
[debug][New Thread 6644.0x15c8]
[debug][Thread 6644.0x1508 exited with code 3]
[debug][Thread 6644.0x1264 exited with code 3]
[debug][Thread 6644.0x2484 exited with code 3]
[debug][Thread 6644.0x15c8 exited with code 3]
[debug][Inferior 1 (process 6644) exited with code 03]
[debug]>>>>>>cb_gdb:
[Inferior 1 (process 6644) exited with code 03]
[debug]> quit
Debugger finished with status 0
You didn't give me any information about what the problem was.
What does it matter? It could have been anything. But in this case the bug that caused the crash was an init order fiasco. A base class constructor tried to access data that was using a virtual getter from derived class. But since the derived part of the class is not yet constructed it's returning random data. This is exactly where the program crashed:
void Terrain_Tile::Put_Object(Game_Object *o)
{
//determine in which object slot the object belongs using its type
const int t=o->Get_Object_Type();
if (goty::is_mover(t)) mover=o;
else rooted=o;
}
Terrain_Tile is a tile object of 2D map in a roguelike game. Game_Object is the base class of game objects, but when you call Get_Object_Type using partly constructed class it returned stuff like -458433939 or whatever for 't'. is_mover() then accessed that index and was greatly out-of-bounds. The way I fixed this bug was removing map handling inside Game_Object when creating an object. It's anyway bad practice, because it assumes that the 2D map exists and also there was that virtual getter problem.
So, you're creating threads before main has started?
Is the problem in a dll?
On linux if I use this code in a simple program:
struct A
{
A()
{
int *a=0;
*a=5;
exit(4);
}
};
A a;
GDB stops correctly at the place of the crash. What happens with your version of GDB if you use this code?