Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QString destructor crash
Qt 6.11 is out! See what's new in the release blog

QString destructor crash

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.5k Views 1 Watching
  • 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
    bkka
    wrote on last edited by
    #1

    I am new to Qt, and immediately I am experiencing the strange issue that simply calling the QString destructor will crash my program. Here is the most minimal example:

    #include <iostream>
    #include <QString>
    
    int main(int argc, char *argv[]) {
    
        std::cout << "before" << std::endl;
        QString* str = new QString("hallo");
        delete str;
        std::cout << "after" << std::endl;
    
        return 0;
    }
    

    The second print statement is never reached. Appearently the issue lies more specifically with the detructor of QArrayDataPointer. The call stack looks like this:
    f7720a3f-5055-4ef3-bf07-2f0eaf4f76a4-image.png

    I am using Qt 6.8.2 on Windows.
    I'm at a loss here. Is something wrong with my installation? Thanks in advance for your help

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Don't mix debug and release libraries. You most likely compile your app in debug mode but link against release Qt dlls.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      B 1 Reply Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher

        Don't mix debug and release libraries. You most likely compile your app in debug mode but link against release Qt dlls.

        B Offline
        B Offline
        bkka
        wrote on last edited by
        #3

        @Christian-Ehrlicher

        Pardon me, but how do I make sure to compile in release? If I set CMAKE_BUILD_TYPE to Release, the issue stays the same

        JonBJ 1 Reply Last reply
        0
        • B bkka

          @Christian-Ehrlicher

          Pardon me, but how do I make sure to compile in release? If I set CMAKE_BUILD_TYPE to Release, the issue stays the same

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by
          #4

          @bkka
          While you await a better answer, I would start by looking at (a) the actual compilation and linker statements executed during the build and (b) the actual DLLs picked up at runtime.

          1 Reply Last reply
          2
          • B bkka has marked this topic as solved on
          • B Offline
            B Offline
            bkka
            wrote on last edited by
            #5

            It turns out I was simply using a different MinGW version than the one Qt was compiled with, for anyone wondering. Anyway, thanks for the replies.

            1 Reply Last reply
            1

            • Login

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