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. "debug assertion failed" error message
QtWS25 Last Chance

"debug assertion failed" error message

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 4 Posters 2.2k 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
    Blackzero
    wrote on 24 Apr 2024, 19:46 last edited by Blackzero
    #1

    I tried to switch compiler from MinGw64 to MSVC64 2019 but when I start the program this problem message comes out what should I do?Screenshot 2024-04-25 024401.png

    C 1 Reply Last reply 25 Apr 2024, 02:22
    0
    • B Blackzero
      24 Apr 2024, 19:46

      I tried to switch compiler from MinGw64 to MSVC64 2019 but when I start the program this problem message comes out what should I do?Screenshot 2024-04-25 024401.png

      C Offline
      C Offline
      ChrisW67
      wrote on 25 Apr 2024, 02:22 last edited by
      #2

      what should I do?

      Fix your code. It could be something as simple as this:

      std::vector<char> v{"h", "i"};
      std::string strList =  { "one", "two" };
      

      giving undefined behaviour. Should be:

      std::vector<char> v{'h', 'i'};
      std::vector<std::string> strList =  { "one", "two" };
      

      or any of a bajillion variations. Since we cannot see your code (or, it seems, even the name of your program) this will be up to you to find. I'd be surprised if your compiler did not output a warning message. Start there.

      B 3 Replies Last reply 25 Apr 2024, 10:03
      0
      • C ChrisW67
        25 Apr 2024, 02:22

        what should I do?

        Fix your code. It could be something as simple as this:

        std::vector<char> v{"h", "i"};
        std::string strList =  { "one", "two" };
        

        giving undefined behaviour. Should be:

        std::vector<char> v{'h', 'i'};
        std::vector<std::string> strList =  { "one", "two" };
        

        or any of a bajillion variations. Since we cannot see your code (or, it seems, even the name of your program) this will be up to you to find. I'd be surprised if your compiler did not output a warning message. Start there.

        B Offline
        B Offline
        Blackzero
        wrote on 25 Apr 2024, 10:03 last edited by
        #3

        @ChrisW67 said in "debug assertion failed" error message:

        what should I do?

        Fix your code. It could be something as simple as this:

        std::vector<char> v{"h", "i"};
        std::string strList =  { "one", "two" };
        

        giving undefined behaviour. Should be:

        std::vector<char> v{'h', 'i'};
        std::vector<std::string> strList =  { "one", "two" };
        

        or any of a bajillion variations. Since we cannot see your code (or, it seems, even the name of your program) this will be up to you to find. I'd be surprised if your compiler did not output a warning message. Start there.

        my code has thousands of lines and several classes but it works for the MinGw compiler and does not work in msvc, this is the include I use

        #include "mainwindow.h"
        #include "ui_mainwindow.h"
        #include <QDebug>
        #include <Windows.h>
        #include "ftd2xx.h"
        #include "cmessagebox.h"
        #include <stdio.h>
        #include <QDebug>
        #include <thread>
        #include <QByteArray>
        #include <QThread>
        #include <QElapsedTimer>
        #include "about.h"
        #include "database.h"
        #include <cstring>
        #include <cstdint>
        #include <chrono>
        #include <cmath>
        #include <fstream>
        #include <iostream>
        #include <QFile>
        #include <QJsonDocument>
        #include <QJsonObject>
        #include <QJsonValue>
        #include <QDebug>
        #include <QSettings>
        #include <QFileDialog>
        #include <QFile>
        #include <QByteArray>
        

        what libraries use xutility

        1 Reply Last reply
        0
        • C ChrisW67
          25 Apr 2024, 02:22

          what should I do?

          Fix your code. It could be something as simple as this:

          std::vector<char> v{"h", "i"};
          std::string strList =  { "one", "two" };
          

          giving undefined behaviour. Should be:

          std::vector<char> v{'h', 'i'};
          std::vector<std::string> strList =  { "one", "two" };
          

          or any of a bajillion variations. Since we cannot see your code (or, it seems, even the name of your program) this will be up to you to find. I'd be surprised if your compiler did not output a warning message. Start there.

          B Offline
          B Offline
          Blackzero
          wrote on 25 Apr 2024, 10:25 last edited by
          #4

          @ChrisW67 said in "debug assertion failed" error message:

          or any of a bajillion variations. Since we cannot see your code (or, it seems, even the name of your program) this will be up to you to find. I'd be surprised if your compiler did not output a warning message. Start there.

          This is my first time using MSVC2019, MSVC2015 is working fine, does MSVC2019 need to be configured first?

          J 1 Reply Last reply 25 Apr 2024, 10:46
          0
          • B Blackzero
            25 Apr 2024, 10:25

            @ChrisW67 said in "debug assertion failed" error message:

            or any of a bajillion variations. Since we cannot see your code (or, it seems, even the name of your program) this will be up to you to find. I'd be surprised if your compiler did not output a warning message. Start there.

            This is my first time using MSVC2019, MSVC2015 is working fine, does MSVC2019 need to be configured first?

            J Offline
            J Offline
            JonB
            wrote on 25 Apr 2024, 10:46 last edited by
            #5

            @Blackzero
            Run your program from MSVC/VS debugger, or click Retry to invoke it just like the dialog says. Get the stack trace from the debugger when it crashes and start from there, standard debugging when developing C++ code.

            B 1 Reply Last reply 25 Apr 2024, 12:06
            1
            • J JonB
              25 Apr 2024, 10:46

              @Blackzero
              Run your program from MSVC/VS debugger, or click Retry to invoke it just like the dialog says. Get the stack trace from the debugger when it crashes and start from there, standard debugging when developing C++ code.

              B Offline
              B Offline
              Blackzero
              wrote on 25 Apr 2024, 12:06 last edited by
              #6

              @JonB said in "debug assertion failed" error message:

              @Blackzero
              Run your program from MSVC/VS debugger, or click Retry to invoke it just like the dialog says. Get the stack trace from the debugger when it crashes and start from there, standard debugging when developing C++ code.

              I have tried it many times but it is still the same, do I have to set msvc 2019 like in this video https://www.youtube.com/watch?v=KCH92zvrHas&t=921s

              J 1 Reply Last reply 25 Apr 2024, 12:17
              0
              • B Blackzero
                25 Apr 2024, 12:06

                @JonB said in "debug assertion failed" error message:

                @Blackzero
                Run your program from MSVC/VS debugger, or click Retry to invoke it just like the dialog says. Get the stack trace from the debugger when it crashes and start from there, standard debugging when developing C++ code.

                I have tried it many times but it is still the same, do I have to set msvc 2019 like in this video https://www.youtube.com/watch?v=KCH92zvrHas&t=921s

                J Offline
                J Offline
                JonB
                wrote on 25 Apr 2024, 12:17 last edited by
                #7

                @Blackzero
                What is "still the same"? If you have a crash/assertion in a C++ program you run it from within debugger, let it crash, and find the *stack trace" to look at.

                B 1 Reply Last reply 26 Apr 2024, 10:27
                0
                • H Offline
                  H Offline
                  hskoglund
                  wrote on 25 Apr 2024, 12:20 last edited by
                  #8

                  Also it seems that you have a mixup of Visual Studio 2019 and Visual Studio 2022, which might explain the error.
                  (The xutility file should be of version 14.29.xxx for Visual Studio 2019.)

                  B 1 Reply Last reply 26 Apr 2024, 10:16
                  3
                  • H hskoglund
                    25 Apr 2024, 12:20

                    Also it seems that you have a mixup of Visual Studio 2019 and Visual Studio 2022, which might explain the error.
                    (The xutility file should be of version 14.29.xxx for Visual Studio 2019.)

                    B Offline
                    B Offline
                    Blackzero
                    wrote on 26 Apr 2024, 10:16 last edited by
                    #9

                    @hskoglund said in "debug assertion failed" error message:

                    Also it seems that you have a mixup of Visual Studio 2019 and Visual Studio 2022, which might explain the error.
                    (The xutility file should be of version 14.29.xxx for Visual Studio 2019.)

                    What do I do now, do I reset Visual Studio 2019?

                    1 Reply Last reply
                    0
                    • J JonB
                      25 Apr 2024, 12:17

                      @Blackzero
                      What is "still the same"? If you have a crash/assertion in a C++ program you run it from within debugger, let it crash, and find the *stack trace" to look at.

                      B Offline
                      B Offline
                      Blackzero
                      wrote on 26 Apr 2024, 10:27 last edited by
                      #10

                      @JonB said in "debug assertion failed" error message:

                      @Blackzero
                      What is "still the same"? If you have a crash/assertion in a C++ program you run it from within debugger, let it crash, and find the *stack trace" to look at.

                      this is what comes out when I try to retry

                      Screenshot 2024-04-26 171921.png

                      J 1 Reply Last reply 26 Apr 2024, 11:32
                      0
                      • B Blackzero
                        26 Apr 2024, 10:27

                        @JonB said in "debug assertion failed" error message:

                        @Blackzero
                        What is "still the same"? If you have a crash/assertion in a C++ program you run it from within debugger, let it crash, and find the *stack trace" to look at.

                        this is what comes out when I try to retry

                        Screenshot 2024-04-26 171921.png

                        J Offline
                        J Offline
                        JonB
                        wrote on 26 Apr 2024, 11:32 last edited by
                        #11

                        @Blackzero OK, and? It tells you what you need to do. Anyway I leave it you, and @hskoglund's suggestion. If you have a mix of VS 19/22 you would need to sort that out.

                        1 Reply Last reply
                        0
                        • C ChrisW67
                          25 Apr 2024, 02:22

                          what should I do?

                          Fix your code. It could be something as simple as this:

                          std::vector<char> v{"h", "i"};
                          std::string strList =  { "one", "two" };
                          

                          giving undefined behaviour. Should be:

                          std::vector<char> v{'h', 'i'};
                          std::vector<std::string> strList =  { "one", "two" };
                          

                          or any of a bajillion variations. Since we cannot see your code (or, it seems, even the name of your program) this will be up to you to find. I'd be surprised if your compiler did not output a warning message. Start there.

                          B Offline
                          B Offline
                          Blackzero
                          wrote on 26 Apr 2024, 17:37 last edited by
                          #12

                          @ChrisW67 said in "debug assertion failed" error message:

                          what should I do?

                          Fix your code. It could be something as simple as this:

                          std::vector<char> v{"h", "i"};
                          std::string strList =  { "one", "two" };
                          

                          giving undefined behaviour. Should be:

                          std::vector<char> v{'h', 'i'};
                          std::vector<std::string> strList =  { "one", "two" };
                          

                          or any of a bajillion variations. Since we cannot see your code (or, it seems, even the name of your program) this will be up to you to find. I'd be surprised if your compiler did not output a warning message. Start there.

                          After I looked at my code, I found this, what I want to do is to change the previous byte to a new byte, do I have to change it and how to change it to make it suitable for msvc 2019.

                              uint8_t array8[] = {114,5,0,240,153,0};
                              std::copy(std::begin({114, 5, 0, 240, 153}), std::end({114, 5, 0, 240, 153}), std::begin(array8));
                          
                          
                          C 1 Reply Last reply 26 Apr 2024, 22:39
                          0
                          • B Blackzero
                            26 Apr 2024, 17:37

                            @ChrisW67 said in "debug assertion failed" error message:

                            what should I do?

                            Fix your code. It could be something as simple as this:

                            std::vector<char> v{"h", "i"};
                            std::string strList =  { "one", "two" };
                            

                            giving undefined behaviour. Should be:

                            std::vector<char> v{'h', 'i'};
                            std::vector<std::string> strList =  { "one", "two" };
                            

                            or any of a bajillion variations. Since we cannot see your code (or, it seems, even the name of your program) this will be up to you to find. I'd be surprised if your compiler did not output a warning message. Start there.

                            After I looked at my code, I found this, what I want to do is to change the previous byte to a new byte, do I have to change it and how to change it to make it suitable for msvc 2019.

                                uint8_t array8[] = {114,5,0,240,153,0};
                                std::copy(std::begin({114, 5, 0, 240, 153}), std::end({114, 5, 0, 240, 153}), std::begin(array8));
                            
                            
                            C Offline
                            C Offline
                            ChrisW67
                            wrote on 26 Apr 2024, 22:39 last edited by ChrisW67
                            #13

                            @Blackzero said in "debug assertion failed" error message:

                            After I looked at my code, I found this, what I want to do is to change the previous byte to a new byte, do I have to change it and how to change it to make it suitable for msvc 2019.

                                uint8_t array8[] = {114,5,0,240,153,0};
                                std::copy(std::begin({114, 5, 0, 240, 153}), std::end({114, 5, 0, 240, 153}), std::begin(array8));
                            

                            What warnings did your compiler issue when it compiled this? I am surprised that mine did not.

                            The first line fills a C-style array with 6 elements as expected.
                            The std::copy() line uses:

                            • a temporary five-element list to get a begin() iterator
                            • a different temporary five-element list to get an end() iterator
                            • tries to put that in the 6-element array8

                            The two input iterators are unrelated and could be massively far apart in memory. That it did not crash the program (regardless of compiler) is luck.

                            I think that, "change the previous byte to a new byte," means you wanted to fill array8 with different bytes and resize it to five elements. You cannot resize a C-style array: you need to track the amount of useful data in the 6-byte buffer by some other means. C-strings use a '\0' byte to flag the end of the string but you do not have the luxury of a flag value in your data. You are also responsible for ensuring you never try to put more than 6-elements in the array.

                            Since this is C++ you should be using std::vector and not C-style arrays. You need to adjust all other code using it.

                            std::vector<uint8_t>array {114,5,0,240,153,0};
                            qDebug() << array;  // std::vector(114, 5, 0, 240, 153, 0)
                            array.pop_back();
                            qDebug() << array;  // std::vector(114, 5, 0, 240, 153)
                            array = std::vector<uint8_t> {1,2,3,4,5,6,7,8};
                            qDebug() << array; // std::vector(1, 2, 3, 4, 5, 6, 7, 8)
                            array = std::vector<uint8_t> {10,9,8};
                            qDebug() << array; // std::vector(10, 9, 8)
                            
                            B 1 Reply Last reply 27 Apr 2024, 15:08
                            2
                            • C ChrisW67
                              26 Apr 2024, 22:39

                              @Blackzero said in "debug assertion failed" error message:

                              After I looked at my code, I found this, what I want to do is to change the previous byte to a new byte, do I have to change it and how to change it to make it suitable for msvc 2019.

                                  uint8_t array8[] = {114,5,0,240,153,0};
                                  std::copy(std::begin({114, 5, 0, 240, 153}), std::end({114, 5, 0, 240, 153}), std::begin(array8));
                              

                              What warnings did your compiler issue when it compiled this? I am surprised that mine did not.

                              The first line fills a C-style array with 6 elements as expected.
                              The std::copy() line uses:

                              • a temporary five-element list to get a begin() iterator
                              • a different temporary five-element list to get an end() iterator
                              • tries to put that in the 6-element array8

                              The two input iterators are unrelated and could be massively far apart in memory. That it did not crash the program (regardless of compiler) is luck.

                              I think that, "change the previous byte to a new byte," means you wanted to fill array8 with different bytes and resize it to five elements. You cannot resize a C-style array: you need to track the amount of useful data in the 6-byte buffer by some other means. C-strings use a '\0' byte to flag the end of the string but you do not have the luxury of a flag value in your data. You are also responsible for ensuring you never try to put more than 6-elements in the array.

                              Since this is C++ you should be using std::vector and not C-style arrays. You need to adjust all other code using it.

                              std::vector<uint8_t>array {114,5,0,240,153,0};
                              qDebug() << array;  // std::vector(114, 5, 0, 240, 153, 0)
                              array.pop_back();
                              qDebug() << array;  // std::vector(114, 5, 0, 240, 153)
                              array = std::vector<uint8_t> {1,2,3,4,5,6,7,8};
                              qDebug() << array; // std::vector(1, 2, 3, 4, 5, 6, 7, 8)
                              array = std::vector<uint8_t> {10,9,8};
                              qDebug() << array; // std::vector(10, 9, 8)
                              
                              B Offline
                              B Offline
                              Blackzero
                              wrote on 27 Apr 2024, 15:08 last edited by Blackzero
                              #14

                              @ChrisW67 said in "debug assertion failed" error message:

                              What warnings did your compiler issue when it compiled this? I am surprised that mine did not.

                              I realized that the previous error went out because it entered the method that contains this, if I don't run the method with the array the application is fine and can run, actually there is a lot of code in that method but all of it only relates to the UI -> this is the only one I suspect, because when I delete the array the error moves to ui->label->settext(" ");, I will try your method.

                              1 Reply Last reply
                              0

                              5/14

                              25 Apr 2024, 10:46

                              topic:navigator.unread, 9
                              • Login

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