program crashed when call QByteArray::resize in win7
-
win7 64bit servicepack 1 , QT5.12.12
program crashed when long time run. debug mode get the error is an uncatched unknow exception; error caused code is QByteArray::resize, error hint on console is C0000374
i donn't know why the resize method cause heap exception.
does someone know this question? -
Unless you're trying to resize to some ridiculous size the crash is unlikely to be caused by resize. It could be just a symptom of some previous fail.
Heap corruption could be almost anything. You could be using a released object, have a leak and run out of virtual space, write out of bounds of some container etc. It's impossible to guess without more information.
If the crash happens after a long run my first guess would be you have a memory leak somewhere and when you call resize it fails due to heap exhaustion or fragmentation. Check what's your memory usage when you crash.
Other than that - if you run it under a debugger what's the full callstack? Maybe the culprit is somewhere higher. What size is the array? What size are you trying to get? Is the array object valid at the point of the call e.g. could it be a member of an object that no longer exists?
-
Thanks for your answer. The code and call stack are confirmed, It looks all right. Finally, I canceled all QByteArrays and used char * to handle them. The problem was solved. My conclusion is that in some cases, memory management of QByteArray will cause failure.
-
Thanks for your answer. The code and call stack are confirmed, It looks all right. Finally, I canceled all QByteArrays and used char * to handle them. The problem was solved. My conclusion is that in some cases, memory management of QByteArray will cause failure.
@qtyangyong said in program crashed when call QByteArray::resize in win7:
is that in some cases, memory management of QByteArray will cause failure.
For sure not.
-
Thanks for your answer. The code and call stack are confirmed, It looks all right. Finally, I canceled all QByteArrays and used char * to handle them. The problem was solved. My conclusion is that in some cases, memory management of QByteArray will cause failure.
@qtyangyong said:
My conclusion is that in some cases, memory management of QByteArray will cause failure.
That's a really bad conclusion. You just have a bug somewhere.