drmemory
drmemory copied to clipboard
APP CRASH Qt 5.6 QMainWindow application built with VS2015
Xref #1589 which is about a QLabel app.
Building a full QMainWindow app with Qt 5.6 RC with VS2015 on Win10 runs under DR but not Dr. Memory:
The app is the sample at Qt/Qt5.6.0/Examples/Qt-5.6/qtbase/widgets/mainwindows/application/
Natively it runs fine:
% PATH=~/extsw/Qt/Qt5.6.0/5.6/msvc2015/bin:$PATH build-application-Desktop_Qt_5_6_0_MSVC2015_32bit-Debug/debug/application.exe
It runs fine under plain DR:
% PATH=~/extsw/Qt/Qt5.6.0/5.6/msvc2015/bin:$PATH ~/DrMemory-Windows-1.10.0-2/dynamorio/bin32/drrun -- build-application-Desktop_Qt_5_6_0_MSVC2015_32bit-Debug/debug/application.exe
It crashes under DrM, full or light:
% PATH=~/extsw/Qt/Qt5.6.0/5.6/msvc2015/bin:$PATH ~/DrMemory-Windows-1.10.0-2/bin/drmemory -light -batch -- build-application-Desktop_Qt_5_6_0_MSVC2015_32bit-Debug/debug/application.exe
~~Dr.M~~ Dr. Memory version 1.10.0
~~Dr.M~~ Running "build-application-Desktop_Qt_5_6_0_MSVC2015_32bit-Debug/debug/application.exe"
~~Dr.M~~
~~Dr.M~~ Error #1: INVALID HEAP ARGUMENT to realloc 0x00790628
~~Dr.M~~ # 0 replace_realloc [d:\drmemory_package\common\alloc_replace.c:2668]
~~Dr.M~~ # 1 Qt5Cored.dll!QListData::realloc_grow [c:\users\qt\work\qt\qtbase\src\corelib\tools\qlist.cpp:156]
~~Dr.M~~ # 2 Qt5Cored.dll!QListData::append [c:\users\qt\work\qt\qtbase\src\corelib\tools\qlist.cpp:182]
~~Dr.M~~ # 3 Qt5Cored.dll!QListData::append [c:\users\qt\work\qt\qtbase\src\corelib\tools\qlist.cpp:192]
~~Dr.M~~ # 4 Qt5Cored.dll!QList<>::append [c:\users\qt\work\qt\qtbase\src\corelib\tools\qlist.h:592]
~~Dr.M~~ # 5 Qt5Cored.dll!qRegisterResourceData [c:\users\qt\work\qt\qtbase\src\corelib\io\qresource.cpp:838]
~~Dr.M~~ # 6 qwindowsd.dll!qInitResources_cursors [c:\users\qt\work\qt\qtbase\src\plugins\platforms\windows\.rcc\debug\qrc_cursors.cpp:754]
~~Dr.M~~ # 7 qwindowsd.dll!`anonymous namespace'::initializer::initializer [c:\users\qt\work\qt\qtbase\src\plugins\platforms\windows\.rcc\debug\qrc_cursors.cpp:768]
~~Dr.M~~ # 8 qwindowsd.dll!`anonymous namespace'::`dynamic initializer for 'dummy'' [c:\users\qt\work\qt\qtbase\src\plugins\platforms\windows\.rcc\debug\qrc_cursors.cpp:770]
~~Dr.M~~ # 9 ucrtbased.dll!initterm +0x48 (0x5e087dd9 <ucrtbased.dll+0xb7dd9>)
~~Dr.M~~ #10 qwindowsd.dll!dllmain_crt_process_attach [f:\dd\vctools\crt\vcstartup\src\startup\dll_dllmain.cpp:65]
~~Dr.M~~ #11 qwindowsd.dll!dllmain_crt_dispatch [f:\dd\vctools\crt\vcstartup\src\startup\dll_dllmain.cpp:133]
~~Dr.M~~ #12 qwindowsd.dll!dllmain_dispatch [f:\dd\vctools\crt\vcstartup\src\startup\dll_dllmain.cpp:182]
~~Dr.M~~ #13 qwindowsd.dll!_DllMainCRTStartup [f:\dd\vctools\crt\vcstartup\src\startup\dll_dllmain.cpp:250]
~~Dr.M~~ #14 ntdll.dll!RtlDecompressBuffer +0xdd (0x77486b8e <ntdll.dll+0x76b8e>)
~~Dr.M~~ #15 ntdll.dll!RtlAnsiCharToUnicodeChar +0x4dd (0x77455ade <ntdll.dll+0x45ade>)
~~Dr.M~~ #16 ntdll.dll!LdrShutdownProcess +0x398 (0x77468189 <ntdll.dll+0x58189>)
~~Dr.M~~ #17 ntdll.dll!LdrShutdownProcess +0x258 (0x77468049 <ntdll.dll+0x58049>)
~~Dr.M~~ #18 ntdll.dll!EtwEventUnregister +0x40f (0x77442240 <ntdll.dll+0x32240>)
~~Dr.M~~ #19 ntdll.dll!RtlAddAccessAllowedAce +0x68e (0x7745e33f <ntdll.dll+0x4e33f>)
~~Dr.M~~ Note: @0:00:03.969 in thread 2968
~~Dr.M~~
~~Dr.M~~ Error #2: UNADDRESSABLE ACCESS: reading 0x00000000-0x00000004 4 byte(s)
~~Dr.M~~ # 0 Qt5Guid.dll!QGuiApplicationPrivate::createEventDispatcher [c:\users\qt\work\qt\qtbase\src\gui\kernel\qguiapplication.cpp:1244]
~~Dr.M~~ # 1 Qt5Widgetsd.dll!QApplicationPrivate::createEventDispatcher [c:\users\qt\work\qt\qtbase\src\widgets\kernel\qapplication.cpp:196]
~~Dr.M~~ # 2 Qt5Cored.dll!QCoreApplication::init [c:\users\qt\work\qt\qtbase\src\corelib\kernel\qcoreapplication.cpp:814]
~~Dr.M~~ # 3 Qt5Cored.dll!QCoreApplication::QCoreApplication [c:\users\qt\work\qt\qtbase\src\corelib\kernel\qcoreapplication.cpp:705]
~~Dr.M~~ # 4 Qt5Guid.dll!QGuiApplication::QGuiApplication [c:\users\qt\work\qt\qtbase\src\gui\kernel\qguiapplication.cpp:577]
~~Dr.M~~ # 5 Qt5Widgetsd.dll!QApplication::QApplication [c:\users\qt\work\qt\qtbase\src\widgets\kernel\qapplication.cpp:563]
~~Dr.M~~ # 6 main [c:\derek\test\qtdemoapp\main.cpp:52]
~~Dr.M~~ Note: @0:00:05.938 in thread 2968
~~Dr.M~~ Note: instruction: mov (%edx) -> %eax
~~Dr.M~~
~~Dr.M~~ ERRORS FOUND:
~~Dr.M~~ 1 unique, 1 total unaddressable access(es)
~~Dr.M~~ 1 unique, 1 total invalid heap argument(s)
~~Dr.M~~ 0 unique, 0 total GDI usage error(s)
~~Dr.M~~ 0 unique, 0 total warning(s)
~~Dr.M~~ ERRORS IGNORED:
~~Dr.M~~ 4 potential error(s) (suspected false positives)
~~Dr.M~~ (details: C:\derek\DrMemory-Windows-1.10.0-2\drmemory\logs\DrMemory-application.exe.308.000\potential_errors.txt)
~~Dr.M~~ Details: C:\derek\DrMemory-Windows-1.10.0-2\drmemory\logs\DrMemory-application.exe.308.000\results.txt
~~Dr.M~~ WARNING: application exited with abnormal code 0xc0000005
Segmentation fault
Debug:
% PATH=~/extsw/Qt/Qt5.6.0/5.6/msvc2015/bin:$PATH ~/DrMemory-Windows-1.10.0-2/bin/drmemory -debug -dr_debug -light -batch -- build-application-Desktop_Qt_5_6_0_MSVC2015_32bit-Debug/debug/application.exe
<Starting application C:\derek\test\build-application-Desktop_Qt_5_6_0_MSVC2015_32bit-Debug\debug\application.exe (1700)>
<Early threads found>
<Initial options = -no_dynamic_options -logdir 'C:\derek\DrMemory-Windows-1.10.0-2\drmemory\logs\dynamorio' -client_lib 'C:\derek\DrMemory-Windows-1.10.0-2\bin\debug\drmemorylib.dll;0;`-light` -logdir `C:\derek\DrMemory-Windows-1.10.0-2\drmemory\logs` -symcache_dir `C:\derek\DrMemory-Windows-1.10.0-2\drmemory\logs\symcache` -lib_blacklist `C:\Windows*.d??,C:\Program Files (x86)\Common Files\Microsoft Shared*.d??,C:\Program Files (x86)\Common Files\Microsoft Shared*.d??` -resfile 1700 ' -code_api -probe_api -msgbox_mask 0 -stack_size 56K -disable_traces -no_enable_traces -max_elide_jmp 0 -max_elide_call 0 -max_bb_instrs 256 -no_shared_traces -bb_ibl_targets -bb_single_restore_prefix -no_shared_trace_ibl_routine -no_enable_reset -no_reset_at_switch_to_os_at_vmm_limit -reset_at_vmm_percent_free_limit 0 -no_reset_at_vmm_full -reset_at_commit_free_limit 0K -reset_every_nth_pending 0 -vm_size 262144K -no_inline_ignored_syscalls -native_exec_default_list '' -no_native_exec_managed_code -no_indcall2direct -no_aslr_dr -pad_jmps_mark_no_trace >
~~Dr.M~~ Dr. Memory version 1.10.0
~~Dr.M~~ Running "build-application-Desktop_Qt_5_6_0_MSVC2015_32bit-Debug/debug/application.exe"
<Application changing protections of system memory at least once (0x7751c000-0x7751f000)>
~~Dr.M~~ ASSERT FAILURE (thread 1204): d:\drmemory_package\common\alloc_replace.c:949: !info->pre_us || pre_us_base != NULL (need base for pre-us!)~~Dr.M~~ WARNING: application exited with abnormal code 0xffffffff
Disabling most features does run:
% PATH=~/extsw/Qt/Qt5.6.0/5.6/msvc2015/bin:$PATH ~/DrMemory-Windows-1.10.0-2/bin/drmemory -leaks_only -no_count_leaks -no_track_allocs -batch -- build-application-Desktop_Qt_5_6_0_MSVC2015_32bit-Debug/debug/application.exe
~~Dr.M~~ Dr. Memory version 1.10.0
~~Dr.M~~ Running "build-application-Desktop_Qt_5_6_0_MSVC2015_32bit-Debug/debug/application.exe"
~~Dr.M~~
~~Dr.M~~ NO ERRORS FOUND:
~~Dr.M~~ 0 unique, 0 total warning(s)
~~Dr.M~~ ERRORS IGNORED:
~~Dr.M~~ Details: C:\derek\DrMemory-Windows-1.10.0-2\drmemory\logs\DrMemory-application.exe.3088.000\results.txt
The same issue is still reproducible with Qt 5.15.0 and MSVC 2019: I get the same "invalid heap" callstack when running with "-light", and I get the same assertion failure when running with debug.
Same problems running with ASAN (built-int VS feature, /fsanitize=address) on qt 5.12. on 5.15 different issue, not on QApplication constructor, but a destructor.
With VLD similar issue with QNetworkAccessManager constructor (and it also cursed on ASAN with any Qt version I checked).
So... GUI + ASAN on Win probably not a thing within a near decade.
Same problems running with ASAN (built-int VS feature, /fsanitize=address) on qt 5.12. on 5.15 different issue, not on QApplication constructor, but a destructor.
With VLD similar issue with QNetworkAccessManager constructor (and it also cursed on ASAN with any Qt version I checked).
So... GUI + ASAN on Win probably not a thing within a near decade.
@mapron hi, how do you solve memory problems (memory leaks, wild pointers, dangling pointers etc.) with QT project on Windows?
@TianpingHsu Hardly solve. Well, Visual Leak Detector (VLD) do some good stuff. /fsanitize=address do something too. But basically I need to apply and revert patch on codebase that disables a lot of thing (Qt networking one of them - none of tools can behave with it). So I just hope linux/mac mem checks catch those... If I have win-only project, I don't even know.
@mapron thanks for your tips.