MuseScore built in Windows with MSVC in Debug mode crashes with assertion failure
Building MuseScore (59594be, but I believe to have seen this a few weeks ago already) on Windows in Debug mode with MSVC results in a crash on start up due to some assertion failure deep in what seems to be MS runtime code, in delete_scalar.cpp
, line 38, operator delete(void* const block) noexcept
Output in MSVC:
HEAP[MuseScore.exe]: Invalid address specified to RtlValidateHeap( 0000000000600000, 000000000A4DE480 )
MuseScore.exe hat einen Haltepunkt ausgelöst.
Debug Assertion Failed!
Program: ...svc.build_x64\mscore....\msvc.install_x64\bin\MuseScore.exe
File: minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp
Line: 904
Expression: _CrtIsValidHeapPointer(block)
Somehow looks like we're freeing something that had been free'd already?
Comments
No crash in Release or RelWithDebInfo mode
And no crash in a MinGW Debug build either
I wouldn't call it Critical, because it doesn't relate to end users. Btw, it is a crash, so critical makes sense here. Anyway, thank you for reporting this issue, I will be able to check it on Wednesday.
From what I can see, the crash comes from the fact that the executable is linked against the debug version of runtime library via
\MDd
flag, https://github.com/musescore/MuseScore/blob/1d014c5cb2e5f2ce0d188e5b2c0…See:
https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
The crash is done on purpose by the runtime debug library as soon as it detects something strange being done with memory handling; I think it could be a problem of the underlying Qt framework, maybe memory allocation/deallocation mismatch from the given output message (a similar "crash" appears with AddressSanitizer for the plugin tests, but this will be solved in Qt 5.12 https://bugreports.qt.io/browse/QTBUG-58524 ).
Long story short: by using
\MD
instead of\MDd
the crash disappears. I don't know if there is maybe a possibility to stop the debug library crash (for example settingASAN_OPTIONS=new_delete_type_mismatch=false
prevents AddressSanitizer "crash" on plugin tests).Strange thing is that I do build using Qt 5.12 since some weeks (beta 1 at the time I reported this)
Rebuilding now, with beta2, let's see...
Edit: it still crashes
In reply to Strange thing is that I do… by Jojo-Schmitz
Well, actually I was not saying that this "bug" (if it is really a bug and not a false positive of MSVC runtime debug libraries) is solved by Qt 5.12, but only that the "bug" of different size in allocating/deallocating memory in Qt Quick was solved in Qt 5.12; and probably in a future release also this bug/possible false positive.
The crash in this bug report happens for me when dealing with QTranslator objects (for example when a QTranslator is deleted, or when calling setLocale function).
But, as I said, simply linking against the regular MSVC runtime (i.e. with
/MD
) seems to be solving this crash.OK, got it. Question is whether with
/MD
we can still use the debugger?Hmm, well, actually with
/MDd
we can't debug at all, as it crashes right at startup...And changing it to
/MT
gets rid of a linker warning LNK4098, LIBCMTD conflicting with other libs, the last remaining warning I didn't fix in #275218: MSVC warnings need to be fixed/MTd
crashes too BTW.I've just added it to my https://github.com/musescore/MuseScore/pull/4041
Fixed in branch master, commit 559ee89127
fix #277056: MuseScore built in Windows with MSVC in Debug mode crashes with assertion failure
and fix MSVC Linker warning LNK4098, LIBCMTD conflicting with other libs
Automatically closed -- issue fixed for 2 weeks with no activity.
Automatically closed -- issue fixed for 2 weeks with no activity.
Automatically closed -- issue fixed for 2 weeks with no activity.
Automatically closed -- issue fixed for 2 weeks with no activity.
Automatically closed -- issue fixed for 2 weeks with no activity.