GDB crash on a simple program with an optimized-out variable.
-
wrote on 13 Sept 2022, 13:48 last edited by
QT creator 8.0.1
GCC 11.2.0
gdb 12.0.90
Ubuntu 22.04.1 LTS
Create a new project, write this, put a breakpoint anywhere in the main function. Run as debug.#include <iostream> using namespace std; int main(){ size_t adr; cout << "Hello World!" << endl; return 0; }
For me, it shows the debug screen, then, after a second*), QT send an error texbox:
"Unexpected GDB Exit - QT Creator
The DGB process terminated."
and
"GDB I/O Error - QT Creator
The process crashed. Process crashed. "During this short period, I can see the "locals" window (the one that automatically displays
variables) is "busy".Occasionally it makes the entire QT-creator crash.
Changing the first line of main() to
size_t adr = 0;
makes the problem go away.
Adding the linecout<<adr<<endl;
also helps. The "locals" window displays a random value for adr.
The name and the type (i checked size_t, int, uint8_t) of the variable do not matter.
Using GDB from the command line, it works (both on the executable made by QTC and manually compiled with "g++ -g -o bla main.cpp"), but the GDB is telling me the variable is optimized out (while both fils were compiled without optimization)
(gdb) print adr $1 = <optimized out>
It looks like the QTCreator has trouble with that optimized out variable. The earlier version (QTC 4.11.0 :)) properly displays "adr | <optmized out>" i "locals" for this code and doesn't crash.
But it may be something wrong with my environment since I encounter another strange behavior: the debugger won't start until I close the console linked to the previously ran and finished program.
The "global debugger log": https://pastebin.com/KKUDtC2E
-
wrote on 16 Sept 2022, 14:18 last edited by
Ubuntu 22.04 ships with a broken GDB (version 12.0.90). See https://forum.qt.io/topic/136693/kubuntu-22-04-qt-creator-the-gdb-process-terminated
Upgrading GDB to version 12.1.0 seems to be the solution.
1/2