Invalid address specified to RtlFreeHeap
-
Windows 10 LTSC Build 19044
I use cmake version 3.31.4, gcc 14.2.0, Vulkan SDK 1.4.304.0, Qt 6.8.1
After I initialize
filename
, memory gets corrupt at the end ofVulkanRenderer::initResources()
What exactly goes wrong here and how to fix it?
Thanks in advance.
=========== vulkanrenderer.cpp =========== void VulkanRenderer::initResources() { VkDevice dev = m_window->device(); m_devFuncs = m_window->vulkanInstance()->deviceFunctions(dev); QString filename = "aaa"; // Issue is there printf("End of void VulkanRenderer::initResources()\n"); }
=========== vulkanrenderer.h =========== #ifndef VULKANRENDERER_H #define VULKANRENDERER_H #include <QVulkanWindow> class VulkanRenderer : public QVulkanWindowRenderer { public: VulkanRenderer(QVulkanWindow *w); void initResources() override; void startNextFrame() override; protected: QVulkanWindow *m_window; QVulkanDeviceFunctions *m_devFuncs; float m_hue = 0; }; #endif // VULKANRENDERER_H
=========== gdb =========== End of void VulkanRenderer::initResources() warning: HEAP[discovering-path-tracer.exe]: warning: Invalid address specified to RtlFreeHeap( 00000000006C0000, 0000000002687410 ) Thread 1 received signal SIGTRAP, Trace/breakpoint trap. 0x00007ffa701aa413 in ntdll!RtlRegisterSecureMemoryCacheCallback () from C:\Windows\SYSTEM32\ntdll.dll (gdb) bt #0 0x00007ffa701aa413 in ntdll!RtlRegisterSecureMemoryCacheCallback () from C:\Windows\SYSTEM32\ntdll.dll #1 0x00007ffa7016cf3c in ntdll!memset () from C:\Windows\SYSTEM32\ntdll.dll #2 0x00007ffa701a92c1 in ntdll!RtlRegisterSecureMemoryCacheCallback () from C:\Windows\SYSTEM32\ntdll.dll #3 0x00007ffa700d5cc1 in ntdll!RtlGetCurrentServiceSessionId () from C:\Windows\SYSTEM32\ntdll.dll #4 0x00007ffa700d5b74 in ntdll!RtlGetCurrentServiceSessionId () from C:\Windows\SYSTEM32\ntdll.dll #5 0x00007ffa700d47b1 in ntdll!RtlFreeHeap () from C:\Windows\SYSTEM32\ntdll.dll #6 0x00007ffa6e00f05b in ucrtbase!_free_base () from C:\Windows\System32\ucrtbase.dll #7 0x00007ff793639492 in QArrayDataPointer<char16_t>::~QArrayDataPointer() () #8 0x00007ff7936399f8 in QString::~QString() () #9 0x00007ff7936320ee in VulkanRenderer::initResources() () #10 0x00007ffa145db128 in QVulkanWindowPrivate::init() () from C:\Qt\6.8.1\mingw_64\bin\Qt6Gui.dll #11 0x00007ffa145dc852 in QVulkanWindow::exposeEvent(QExposeEvent*) () from C:\Qt\6.8.1\mingw_64\bin\Qt6Gui.dll #12 0x00007ffa14151138 in QWindow::event(QEvent*) () from C:\Qt\6.8.1\mingw_64\bin\Qt6Gui.dll #13 0x00007ffa139b6355 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from C:\Qt\6.8.1\mingw_64\bin\Qt6Widgets.dll #14 0x00007ffa14b8200a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from C:\Qt\6.8.1\mingw_64\bin\Qt6Core.dll #15 0x00007ffa14104ec1 in QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent*) () from C:\Qt\6.8.1\mingw_64\bin\Qt6Gui.dll #16 0x00007ffa1415327c in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from C:\Qt\6.8.1\mingw_64\bin\Qt6Gui.dll #17 0x00007ffa141534f7 in QWindowSystemInterface::flushWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from C:\Qt\6.8.1\mingw_64\bin\Qt6Gui.dll #18 0x00007ffa2b41b20b in qwindows!qt_plugin_instance () from C:\Qt\6.8.1\mingw_64\plugins\platforms\qwindows.dll #19 0x00007ffa2b45e17f in qwindows!qt_plugin_instance () from C:\Qt\6.8.1\mingw_64\plugins\platforms\qwindows.dll #20 0x00007ffa2b3c65bd in qwindows!qt_plugin_instance () from C:\Qt\6.8.1\mingw_64\plugins\platforms\qwindows.dll #21 0x00007ffa6fd2e858 in USER32!CallWindowProcW () from C:\Windows\System32\user32.dll #22 0x00007ffa6fd2e3dc in USER32!DispatchMessageW () from C:\Windows\System32\user32.dll #23 0x00007ffa6fd40c93 in USER32!SendMessageTimeoutW () from C:\Windows\System32\user32.dll #24 0x00007ffa70150e64 in ntdll!KiUserCallbackDispatcher () from C:\Windows\SYSTEM32\ntdll.dll #25 0x00007ffa6df41704 in win32u!NtUserDispatchMessage () from C:\Windows\System32\win32u.d
=========== CMakeLists.txt =========== cmake_minimum_required(VERSION 3.16) # Qt 6 requires CMake >= 3.16 set(PROJNAME "discovering-path-tracer") project(${PROJNAME} LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) file(GLOB_RECURSE SOURCE_FILES # idk what is the best practice for src file management, so I'll do this for now src/*.cpp src/*.c src/*.hpp src/*.h ) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) add_executable(${PROJNAME} ${SOURCE_FILES}) # Qt configuration find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets Concurrent ) target_link_libraries(${PROJNAME} PRIVATE Qt6::Core Qt6::Gui Qt6::Widgets Qt6::Concurrent ) qt_standard_project_setup() # Vulkan configuration find_package(Vulkan REQUIRED) target_include_directories(${PROJNAME} PRIVATE ${Vulkan_INCLUDE_DIRS}) target_link_libraries(${PROJNAME} PRIVATE ${Vulkan_LIBRARIES}) # Optionally, set Vulkan SDK path if not automatically found if(NOT Vulkan_FOUND) message(FATAL_ERROR "Vulkan SDK not found. Please set Vulkan_INCLUDE_DIRS and Vulkan_LIBRARIES manually.") endif() target_include_directories(${PROJNAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) # Platform-specific configuration if(WIN32) add_definitions(-DVK_USE_PLATFORM_WIN32_KHR) elseif(APPLE) add_definitions(-DVK_USE_PLATFORM_MACOS_MVK) elseif(UNIX AND NOT APPLE) add_definitions(-DVK_USE_PLATFORM_XCB_KHR) endif() # set_target_properties(${PROJNAME} PROPERTIES # WIN32_EXECUTABLE TRUE # MACOSX_BUNDLE TRUE # ) # Add compiler warnings if(MSVC) target_compile_options(${PROJNAME} PRIVATE /W4 /WX) else() target_compile_options(${PROJNAME} PRIVATE -Wall -Wextra -pedantic -Werror) endif()
-
First observation is that initializing
filename
there seem to have no purpose i.e., create it and immediately destroy it. Should not cause an issue though.You look to be using the Qt Online Installer deployment of Qt 6.8.1 for MingW. IIRC, this is built with GCC 13.x (certainly what shipped with the online installer for me). You claim to be building your application with GCC 14.x. Possible that you have a ABI difference from mixed libraries.
-
Thank you a lot! Using GCC 13.x solved the problem. It also solved the issue with
WIN32_EXECUTABLE TRUE
CMake target property causing the window to crash early.For anyone else encountering this issue, set the environment variable for the compiler path to point to Qt/Tools/.../bin directory to make sure that GCC 13.x is used instead of GCC 14.x
-