"debug assertion failed" error message
-
@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?
@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. -
@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.@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
-
@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
@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. -
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.)@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?
-
@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.@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
-
@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
@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.
-
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.
@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));
-
@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));
@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.
Thestd::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)
-
@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.
Thestd::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)
@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.