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 causing Memory Error
Forum Updated to NodeBB v4.3 + New Features

QString causing Memory Error

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 4 Posters 1.2k Views 2 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.
  • P Pawx

    @SGaist Hey,

    thanks for your quick reply. We are using Windows 10 and Windows 11, both 64 bit.

    Christian EhrlicherC Online
    Christian EhrlicherC Online
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on last edited by Christian Ehrlicher
    #4

    You are mixing debug and release dlls. How do you build / link your app? Please use cmake or qmake.

    /edit: What should this line do/ why is it needed:

    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt6Widgets_EXECUTABLE_COMPILE_FLAGS}")

    The include and add_definitions call is also not needed since you link against the imported QtWidgets target.

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

    C 1 Reply Last reply
    0
    • Christian EhrlicherC Christian Ehrlicher

      You are mixing debug and release dlls. How do you build / link your app? Please use cmake or qmake.

      /edit: What should this line do/ why is it needed:

      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt6Widgets_EXECUTABLE_COMPILE_FLAGS}")

      The include and add_definitions call is also not needed since you link against the imported QtWidgets target.

      C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #5

      @Christian-Ehrlicher For my education, how do you determine this? Bitter experience? Is there something in the original information that I am missing?

      Christian EhrlicherC 1 Reply Last reply
      0
      • C ChrisW67

        @Christian-Ehrlicher For my education, how do you determine this? Bitter experience? Is there something in the original information that I am missing?

        Christian EhrlicherC Online
        Christian EhrlicherC Online
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #6

        @ChrisW67 said in QString causing Memory Error:

        Bitter experience? Is there something in the original information that I am missing?

        This looks like something this way - the memory is allocated in main.cpp - therefore the e.g. msvc debug allocator is used but deleted within the Qt dll so the release (de)allocator is used which causes such problems. Yes I've seen such problems more than once when mixing debug and release libs.

        The op should take a look with e.g. dependency walker or 'dependencies gui' (better) to not mix debug and release libs.

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

        P 1 Reply Last reply
        4
        • Christian EhrlicherC Christian Ehrlicher

          @ChrisW67 said in QString causing Memory Error:

          Bitter experience? Is there something in the original information that I am missing?

          This looks like something this way - the memory is allocated in main.cpp - therefore the e.g. msvc debug allocator is used but deleted within the Qt dll so the release (de)allocator is used which causes such problems. Yes I've seen such problems more than once when mixing debug and release libs.

          The op should take a look with e.g. dependency walker or 'dependencies gui' (better) to not mix debug and release libs.

          P Offline
          P Offline
          Pawx
          wrote on last edited by Pawx
          #7

          @Christian-Ehrlicher

          How do i check the debug/release versions? I downloaded the dependencies gui and opened my executable in it.

          It gave me an output like this:
          3c01765e-7170-413d-a358-06f60d362a47-image.png

          We are only using the QTBase Repository and compiled it ourselfs, if that information helps.
          My mate actually got the code to work by installing qt via the installer, but i wanted to look further into this to see if we are able to fix it.

          Christian EhrlicherC 1 Reply Last reply
          0
          • P Pawx

            @Christian-Ehrlicher

            How do i check the debug/release versions? I downloaded the dependencies gui and opened my executable in it.

            It gave me an output like this:
            3c01765e-7170-413d-a358-06f60d362a47-image.png

            We are only using the QTBase Repository and compiled it ourselfs, if that information helps.
            My mate actually got the code to work by installing qt via the installer, but i wanted to look further into this to see if we are able to fix it.

            Christian EhrlicherC Online
            Christian EhrlicherC Online
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #8

            @Pawx Since you're using MinGW which you did not told us, my assumption can not be correct.
            What I see is that you're using another MinGW version than the one provided by Qt - make sure to use the MinGW compiler and libs (libstdc++6.dll/libgcc_s_seh-1.dll) provided by Qt.

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

            P 1 Reply Last reply
            1
            • Christian EhrlicherC Christian Ehrlicher

              @Pawx Since you're using MinGW which you did not told us, my assumption can not be correct.
              What I see is that you're using another MinGW version than the one provided by Qt - make sure to use the MinGW compiler and libs (libstdc++6.dll/libgcc_s_seh-1.dll) provided by Qt.

              P Offline
              P Offline
              Pawx
              wrote on last edited by
              #9

              @Christian-Ehrlicher

              How do i make sure to use the correct MinGW version? Is this something i can configure in my CMakeList or where can i adjust this?

              Christian EhrlicherC 1 Reply Last reply
              0
              • P Pawx

                @Christian-Ehrlicher

                How do i make sure to use the correct MinGW version? Is this something i can configure in my CMakeList or where can i adjust this?

                Christian EhrlicherC Online
                Christian EhrlicherC Online
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #10

                @Pawx said in QString causing Memory Error:

                How do i make sure to use the correct MinGW version?

                Use the correct kit settings and set the PATH correct.

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

                P 1 Reply Last reply
                0
                • Christian EhrlicherC Christian Ehrlicher

                  @Pawx said in QString causing Memory Error:

                  How do i make sure to use the correct MinGW version?

                  Use the correct kit settings and set the PATH correct.

                  P Offline
                  P Offline
                  Pawx
                  wrote on last edited by
                  #11

                  @Christian-Ehrlicher

                  Is there a way to configure the kits without qt creator? Currently i dont have QTCreator installed and just compiled the repository and built it. Is QTCreator mandatory/recommended to use?

                  Christian EhrlicherC 1 Reply Last reply
                  0
                  • P Pawx

                    @Christian-Ehrlicher

                    Is there a way to configure the kits without qt creator? Currently i dont have QTCreator installed and just compiled the repository and built it. Is QTCreator mandatory/recommended to use?

                    Christian EhrlicherC Online
                    Christian EhrlicherC Online
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #12

                    @Pawx said in QString causing Memory Error:

                    QTCreator installed and just compiled the repository and built it

                    So you compiled Qt by yourself?
                    What MinGW version do you use?

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

                    P 1 Reply Last reply
                    0
                    • Christian EhrlicherC Christian Ehrlicher

                      @Pawx said in QString causing Memory Error:

                      QTCreator installed and just compiled the repository and built it

                      So you compiled Qt by yourself?
                      What MinGW version do you use?

                      P Offline
                      P Offline
                      Pawx
                      wrote on last edited by Pawx
                      #13

                      @Christian-Ehrlicher

                      Yes, i compiled it myself.
                      I got my mingw from winlabs, and its version file says:

                      winlibs personal build version gcc-13.2.0-llvm-17.0.6-mingw-w64ucrt-11.0.1-r5
                      
                      This is the winlibs Intel/AMD 64-bit standalone build of:
                      - GCC 13.2.0
                      - GDB 14.1
                      - LLVM/Clang/LLD/LLDB 17.0.6
                      - MinGW-w64 11.0.1 (linked with ucrt)
                      - GNU Binutils 2.42
                      - GNU Make 4.4.1
                      - PExports 0.47
                      - dos2unix 7.5.2
                      - Yasm 1.3.0
                      - NASM 2.16.01
                      - JWasm 2.12pre
                      - ccache version 4.9
                      - CMake 3.28.2
                      - ninja 1.11.1.git.kitware.jobserver-1
                      - Doxygen 1.10.0
                      
                      Thread model: posix
                      Runtime library: UCRT (Windows 10 or higher, or when [Update for Universal C Runtime](https://support.microsoft.com/en-us/topic/update-for-universal-c-runtime-in-windows-c0514201-7fe6-95a3-b0a5-287930f3560c) is installed on older Windows versions, not supported on systems older than Windows 7 SP1 and Windows Server 2008 R2 SP1)
                      
                      This build was compiled with GCC 13.2.0 and packaged on 2024-02-03.
                      
                      Please check out http://winlibs.com/ for the latest personal build.
                      
                      Christian EhrlicherC 1 Reply Last reply
                      0
                      • P Pawx

                        @Christian-Ehrlicher

                        Yes, i compiled it myself.
                        I got my mingw from winlabs, and its version file says:

                        winlibs personal build version gcc-13.2.0-llvm-17.0.6-mingw-w64ucrt-11.0.1-r5
                        
                        This is the winlibs Intel/AMD 64-bit standalone build of:
                        - GCC 13.2.0
                        - GDB 14.1
                        - LLVM/Clang/LLD/LLDB 17.0.6
                        - MinGW-w64 11.0.1 (linked with ucrt)
                        - GNU Binutils 2.42
                        - GNU Make 4.4.1
                        - PExports 0.47
                        - dos2unix 7.5.2
                        - Yasm 1.3.0
                        - NASM 2.16.01
                        - JWasm 2.12pre
                        - ccache version 4.9
                        - CMake 3.28.2
                        - ninja 1.11.1.git.kitware.jobserver-1
                        - Doxygen 1.10.0
                        
                        Thread model: posix
                        Runtime library: UCRT (Windows 10 or higher, or when [Update for Universal C Runtime](https://support.microsoft.com/en-us/topic/update-for-universal-c-runtime-in-windows-c0514201-7fe6-95a3-b0a5-287930f3560c) is installed on older Windows versions, not supported on systems older than Windows 7 SP1 and Windows Server 2008 R2 SP1)
                        
                        This build was compiled with GCC 13.2.0 and packaged on 2024-02-03.
                        
                        Please check out http://winlibs.com/ for the latest personal build.
                        
                        Christian EhrlicherC Online
                        Christian EhrlicherC Online
                        Christian Ehrlicher
                        Lifetime Qt Champion
                        wrote on last edited by
                        #14

                        I would try with the pre-compiled Qt libs + MinGW from Qt first.

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

                        1 Reply Last reply
                        0

                        • Login

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