Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. GDB crash on a simple program with an optimized-out variable.
Forum Updated to NodeBB v4.3 + New Features

GDB crash on a simple program with an optimized-out variable.

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
2 Posts 2 Posters 853 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bartekltg
    wrote on 13 Sept 2022, 13:48 last edited by
    #1

    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 line

        cout<<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

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cristian-adam
      wrote on 16 Sept 2022, 14:18 last edited by
      #2

      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 Reply Last reply
      2

      1/2

      13 Sept 2022, 13:48

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved