ngscopeclient / scopehal-apps

ngscopeclient and other client applications for libscopehal.
https://www.ngscopeclient.org/
BSD 3-Clause "New" or "Revised" License
560 stars 87 forks source link

ngscopeclient Mingw64/ Windows10 exception at start seems related to TextureManager::LoadTexture()/vk::raii::Image::bindMemory() #498

Closed bvernoux closed 1 year ago

bvernoux commented 1 year ago

Build done with mingw64 latest version with commit https://github.com/glscopeclient/scopehal-apps/commit/d611cbae57684b0505b2ca846d444b94b9ad2786

See backtrace with gdb
(gdb) bt
#0  0x00007ffc512bf1e7 in msvcrt!abort () from C:\Windows\System32\msvcrt.dll
#1  0x00007ffc0a552b56 in ?? ()
   from C:\msys64\home\bvern\glscopeclient_release_glslang_static\libstdc++-6.dll
#2  0x00007ffc0a545706 in ?? ()
   from C:\msys64\home\bvern\glscopeclient_release_glslang_static\libstdc++-6.dll
#3  0x00007ffc0a642173 in ?? ()
   from C:\msys64\home\bvern\glscopeclient_release_glslang_static\libstdc++-6.dll
#4  0x00007ffc0a64b386 in ?? ()
   from C:\msys64\home\bvern\glscopeclient_release_glslang_static\libstdc++-6.dll
#5  0x00007ff74d75c904 in vk::(anonymous namespace)::throwResultException (
    result=<optimized out>,
    message=message@entry=0x7ff74d79510f <vtable for std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<S
CPIConsoleDialog::DoRender()::{lambda()#1}> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::*)(), std::__future_base::_Async_state_impl<std::thread::_I
nvoker<std::tuple<SCPIConsoleDialog::DoRender()::{lambda()#1}> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*> > >+503> "vk::Image::bindMemory")
    at C:/VulkanSDK/1.3.224.1/Include/vulkan/vulkan.hpp:5996
#6  0x00007ff74d56179b in vk::resultCheck (
    message=0x7ff74d79510f <vtable for std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<SCPIConsoleDial
og::DoRender()::{lambda()#1}> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::*)(), std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tu
ple<SCPIConsoleDialog::DoRender()::{lambda()#1}> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*> > >+503> "vk::Image::bindMemory", result=<optimized o
ut>)
    at C:/VulkanSDK/1.3.224.1/Include/vulkan/vulkan.hpp:6169
--Type <RET> for more, q to quit, c to continue without paging--
#7  vk::raii::Image::bindMemory (memoryOffset=0, memory=..., this=0x298cf39bef0)
    at C:/VulkanSDK/1.3.224.1/Include/vulkan/vulkan_raii.hpp:10498
#8  Texture::Texture (this=0x298cf39bef0, device=..., imageInfo=..., srcBuf=..., width=24,
    height=24, mgr=0x298cf2f8ef8)
    at C:\msys64\home\bvern\scopehal-apps\src\ngscopeclient\TextureManager.cpp:59
#9  0x00007ff74d562645 in std::_Construct<Texture, vk::raii::Device&, vk::ImageCreateInfo&, vk::raii::Buffer&, int&, int&, TextureManager*> (__p=0x298cf39bef0)
    at C:/msys64/mingw64/include/c++/12.2.0/bits/stl_construct.h:119
#10 std::allocator_traits<std::allocator<void> >::construct<Texture, vk::raii::Device&, vk::ImageCreateInfo&, vk::raii::Buffer&, int&, int&, TextureManager*> (__p=0x298cf39bef0)
    at C:/msys64/mingw64/include/c++/12.2.0/bits/alloc_traits.h:635
#11 std::_Sp_counted_ptr_inplace<Texture, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<vk::raii::Device&, vk::ImageCreateInfo&, vk::raii::Buffer&, int&, int&,
TextureManager*> (__a=..., this=0x298cf39bee0)
    at C:/msys64/mingw64/include/c++/12.2.0/bits/shared_ptr_base.h:604
#12 std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<Texture, std::allocator<void>, vk::raii::Device&, vk::ImageCreateInfo&, vk::raii::Buffer&, int&, int&, TextureManager*> (

    __a=..., __p=<optimized out>, this=<optimized out>)
    at C:/msys64/mingw64/include/c++/12.2.0/bits/shared_ptr_base.h:971
#13 std::__shared_ptr<Texture, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<void>, vk::raii::Device&, vk::ImageCreateInfo&, vk::raii::Buffer&, int&, int&, TextureManager*> (__ta
g=...,
    this=<optimized out>) at C:/msys64/mingw64/include/c++/12.2.0/bits/shared_ptr_base.h:1712
#14 std::shared_ptr<Texture>::shared_ptr<std::allocator<void>, vk::raii::Device&, vk::ImageCreateInfo&, vk::raii::Buffer&, int&, int&, TextureManager*> (__tag=..., this=<optimized out>)
    at C:/msys64/mingw64/include/c++/12.2.0/bits/shared_ptr.h:464
#15 std::make_shared<Texture, vk::raii::Device&, vk::ImageCreateInfo&, vk::raii::Buffer&, int&, int
&, TextureManager*> () at C:/msys64/mingw64/include/c++/12.2.0/bits/shared_ptr.h:1010
#16 TextureManager::LoadTexture (this=this@entry=0x298cf2f8ef8, name="foo",
    path="C:\\msys64\\home\\bvern\\glscopeclient_release_glslang_static/icons/24x24/trigger-start.png") at C:\msys64\home\bvern\scopehal-apps\src\ngscopeclient\TextureManager.cpp:304
#17 0x00007ff74d52c900 in MainWindow::MainWindow (this=this@entry=0x298cf2f8a40, queue=...)
    at C:\msys64\home\bvern\scopehal-apps\src\ngscopeclient\MainWindow.cpp:107
#18 0x00007ff74d75d58a in std::make_unique<MainWindow, vk::raii::Queue&> ()
    at C:/msys64/mingw64/include/c++/12.2.0/bits/unique_ptr.h:1064
#19 main (argc=<optimized out>, argv=<optimized out>)
    at C:\msys64\home\bvern\scopehal-apps\src\ngscopeclient\main.cpp:133
bvernoux commented 1 year ago

After more investigation with gdb doing step by step the issue appears after execution of line scopehal-apps/src/ngscopeclient/TextureManager.cpp:304 m_textures[name] = make_shared<Texture>(*g_vkComputeDevice, imageInfo, stagingBuf, width, height, this); (gdb) bt

0 TextureManager::LoadTexture (this=this@entry=0x1dc45ce4428, name="foo", path="C:\msys64\home\bvern\glscopeclient_release_glslang_static/icons/24x24/trigger-start.png")

at C:\msys64\home\bvern\scopehal-apps\src\ngscopeclient\TextureManager.cpp:304

1 0x00007ff74d52c900 in MainWindow::MainWindow (this=this@entry=0x1dc45ce3f70, queue=...) at C:\msys64\home\bvern\scopehal-apps\src\ngscopeclient\MainWindow.cpp:107

2 0x00007ff74d75d58a in std::make_unique<MainWindow, vk::raii::Queue&> () at C:/msys64/mingw64/include/c++/12.2.0/bits/unique_ptr.h:1064

3 main (argc=, argv=) at C:\msys64\home\bvern\scopehal-apps\src\ngscopeclient\main.cpp:133

Then after few step with gdb the exception happen when calling vk::raii::Image::bindMemory() (when calling scopehal-apps\src\ngscopeclient\TextureManager.cpp:59 m_image.bindMemory(**m_deviceMemory, 0); See gdb bt

(gdb) bt
#0  vk::(anonymous namespace)::throwResultException (result=vk::Result::eErrorValidationFailedEXT,
    message=message@entry=0x7ff74d79510f <vtable for std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<SCPIConsoleDialog::DoRender
()::{lambda()#1}> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::*)(), std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<SCPIConsoleDialog::DoRender()::{la
mbda()#1}> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*> > >+503> "vk::Image::bindMemory")
    at C:/VulkanSDK/1.3.224.1/Include/vulkan/vulkan.hpp:5973
#1  0x00007ff74d56179b in vk::resultCheck (
    message=0x7ff74d79510f <vtable for std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<SCPIConsoleDialog::DoRender()::{lambda()#
1}> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::*)(), std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<SCPIConsoleDialog::DoRender()::{lambda()#1}> >,
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*> > >+503> "vk::Image::bindMemory",
    result=<optimized out>) at C:/VulkanSDK/1.3.224.1/Include/vulkan/vulkan.hpp:6169
#2  vk::raii::Image::bindMemory (memoryOffset=0, memory=..., this=0x1dc45d701b0) at C:/VulkanSDK/1.3.224.1/Include/vulkan/vulkan_raii.hpp:10498
#3  Texture::Texture (this=0x1dc45d701b0, device=..., imageInfo=..., srcBuf=..., width=24, height=24, mgr=0x1dc45ce4428)
    at C:\msys64\home\bvern\scopehal-apps\src\ngscopeclient\TextureManager.cpp:59
#4  0x00007ff74d562645 in std::_Construct<Texture, vk::raii::Device&, vk::ImageCreateInfo&, vk::raii::Buffer&, int&, int&, TextureManager*> (__p=0x1dc45d701b0)
    at C:/msys64/mingw64/include/c++/12.2.0/bits/stl_construct.h:119
#5  std::allocator_traits<std::allocator<void> >::construct<Texture, vk::raii::Device&, vk::ImageCreateInfo&, vk::raii::Buffer&, int&, int&, TextureManager*> (__p=0x1dc45d701b0)
    at C:/msys64/mingw64/include/c++/12.2.0/bits/alloc_traits.h:635
#6  std::_Sp_counted_ptr_inplace<Texture, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<vk::raii::Device&, vk::ImageCreateInfo&, vk::raii::Buffer&, int&, int&, TextureManager*> (__a=...,
 this=0x1dc45d701a0) at C:/msys64/mingw64/include/c++/12.2.0/bits/shared_ptr_base.h:604
#7  std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<Texture, std::allocator<void>, vk::raii::Device&, vk::ImageCreateInfo&, vk::raii::Buffer&, int&, int&, TextureManager*>
    (__a=..., __p=<optimized out>, this=<optimized out>) at C:/msys64/mingw64/include/c++/12.2.0/bits/shared_ptr_base.h:971
#8  std::__shared_ptr<Texture, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<void>, vk::raii::Device&, vk::ImageCreateInfo&, vk::raii::Buffer&, int&, int&, TextureManager*> (
    __tag=..., this=<optimized out>) at C:/msys64/mingw64/include/c++/12.2.0/bits/shared_ptr_base.h:1712
#9  std::shared_ptr<Texture>::shared_ptr<std::allocator<void>, vk::raii::Device&, vk::ImageCreateInfo&, vk::raii::Buffer&, int&, int&, TextureManager*> (__tag=..., this=<optimized out>)
    at C:/msys64/mingw64/include/c++/12.2.0/bits/shared_ptr.h:464
#10 std::make_shared<Texture, vk::raii::Device&, vk::ImageCreateInfo&, vk::raii::Buffer&, int&, int&, TextureManager*> () at C:/msys64/mingw64/include/c++/12.2.0/bits/shared_ptr.h:1010
#11 TextureManager::LoadTexture (this=this@entry=0x1dc45ce4428, name="foo", path="C:\\msys64\\home\\bvern\\glscopeclient_release_glslang_static/icons/24x24/trigger-start.png")
    at C:\msys64\home\bvern\scopehal-apps\src\ngscopeclient\TextureManager.cpp:304
#12 0x00007ff74d52c900 in MainWindow::MainWindow (this=this@entry=0x1dc45ce3f70, queue=...) at C:\msys64\home\bvern\scopehal-apps\src\ngscopeclient\MainWindow.cpp:107
#13 0x00007ff74d75d58a in std::make_unique<MainWindow, vk::raii::Queue&> () at C:/msys64/mingw64/include/c++/12.2.0/bits/unique_ptr.h:1064
#14 main (argc=<optimized out>, argv=<optimized out>) at C:\msys64\home\bvern\scopehal-apps\src\ngscopeclient\main.cpp:133
bvernoux commented 1 year ago

See https://hydrabus.com/ngscopeclient/vulkaninfoSDK.txt More details with Vulkan Validation (with all debug info) image

ngscopeclient.exe
VUID-vkBindImageMemory-memory-01047(ERROR / SPEC): msgNum: -1558817633 - Validation Error: [ VUID-vkBindImageMemory-memory-01047 ] Object 0: handle = 0xa21a4e0000000030, type = VK_OBJECT_TYPE_DEVICE_MEMORY; | MessageID = 0xa316549f | vkBindImageMemory()(): MemoryRequirements->memoryTypeBits (0x102) for this object type are not compatible with the memory type (0x7) of VkDeviceMemory 0xa21a4e0000000030[]. The Vulkan spec states: memory must have been allocated using one of the memory types allowed in the memoryTypeBits member of the VkMemoryRequirements structure returned from a call to vkGetImageMemoryRequirements with image (https://vulkan.lunarg.com/doc/view/1.3.224.1/windows/1.3-extensions/vkspec.html#VUID-vkBindImageMemory-memory-01047)
    Objects: 1
        [0] 0xa21a4e0000000030, type: 8, name: NULL
bvernoux commented 1 year ago

Issue fixed with https://github.com/glscopeclient/scopehal-apps/commit/4c3ba38d7660e1ff598f42c8dbff7a11c9ac12e3