inexorgame / vulkan-renderer

A new 3D game engine for Linux and Windows using C++20 and Vulkan API 1.3, in very early but ongoing development
https://inexor.org
MIT License
777 stars 34 forks source link

AddressSanitizer: SEGV on unknown address #469

Closed IAmNotHanni closed 2 years ago

IAmNotHanni commented 2 years ago

Describe The Bug

When I build and run current main on Linux Mint 20.3, I get an error.

Steps To Reproduce

git clone https://github.com/inexorgame/vulkan-renderer.git
cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-fsanitize=address,undefined,leak"
cmake --build build

Expected Behavior

You should be able to see the 2 octrees we currently render in main branch

Affected Code

The entire code base

Operating System

Linux Mint 20.3 Cinnamon

Application Version

cab5078

Additional Context

I just installed latest Mint 20.3, it could be possible something is missing. Vulkan cube application is running though.

Relevant Log Output

==8506==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x000000b0d057 bp 0x7ffd1821bb70 sp 0x7ffd1821b840 T0)
==8506==The signal is caused by a READ memory access.
==8506==Hint: address points to the zero page.
    #0 0xb0d057 in VmaAllocator_T::GetBufferMemoryRequirements(VkBuffer_T*, VkMemoryRequirements&, bool&, bool&) const /home/johannes/.conan/data/vulkan-memory-allocator/2.3.0/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/vk_mem_alloc.h:15186:9
    #1 0xb270de in vmaCreateBuffer /home/johannes/.conan/data/vulkan-memory-allocator/2.3.0/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/vk_mem_alloc.h:17508:20
    #2 0xb9f472 in inexor::vulkan_renderer::wrapper::GPUMemoryBuffer::GPUMemoryBuffer(inexor::vulkan_renderer::wrapper::Device const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long const&, unsigned int const&, VmaMemoryUsage const&) /home/johannes/Inexor/vulkan-renderer/src/vulkan-renderer/wrapper/gpu_memory_buffer.cpp:41:29
    #3 0xb9fc1b in inexor::vulkan_renderer::wrapper::GPUMemoryBuffer::GPUMemoryBuffer(inexor::vulkan_renderer::wrapper::Device const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long const&, void*, unsigned long, unsigned int const&, VmaMemoryUsage const&) /home/johannes/Inexor/vulkan-renderer/src/vulkan-renderer/wrapper/gpu_memory_buffer.cpp:54:7
    #4 0xbced25 in inexor::vulkan_renderer::wrapper::StagingBuffer::StagingBuffer(inexor::vulkan_renderer::wrapper::Device const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, void*, unsigned long) /home/johannes/Inexor/vulkan-renderer/src/vulkan-renderer/wrapper/staging_buffer.cpp:13:7
    #5 0xba5647 in inexor::vulkan_renderer::wrapper::GpuTexture::create_texture(void*, unsigned long) /home/johannes/Inexor/vulkan-renderer/src/vulkan-renderer/wrapper/gpu_texture.cpp:50:19
    #6 0xba50f6 in inexor::vulkan_renderer::wrapper::GpuTexture::GpuTexture(inexor::vulkan_renderer::wrapper::Device const&, inexor::vulkan_renderer::wrapper::CpuTexture const&) /home/johannes/Inexor/vulkan-renderer/src/vulkan-renderer/wrapper/gpu_texture.cpp:20:5
    #7 0x7d9d05 in decltype(new ((void*)(0))inexor::vulkan_renderer::wrapper::GpuTexture(std::declval<inexor::vulkan_renderer::wrapper::Device&>(), std::declval<inexor::vulkan_renderer::wrapper::CpuTexture&>())) std::construct_at<inexor::vulkan_renderer::wrapper::GpuTexture, inexor::vulkan_renderer::wrapper::Device&, inexor::vulkan_renderer::wrapper::CpuTexture&>(inexor::vulkan_renderer::wrapper::GpuTexture*, inexor::vulkan_renderer::wrapper::Device&, inexor::vulkan_renderer::wrapper::CpuTexture&) /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/stl_construct.h:97:39
    #8 0x7d81d0 in void std::allocator_traits<std::allocator<inexor::vulkan_renderer::wrapper::GpuTexture> >::construct<inexor::vulkan_renderer::wrapper::GpuTexture, inexor::vulkan_renderer::wrapper::Device&, inexor::vulkan_renderer::wrapper::CpuTexture&>(std::allocator<inexor::vulkan_renderer::wrapper::GpuTexture>&, inexor::vulkan_renderer::wrapper::GpuTexture*, inexor::vulkan_renderer::wrapper::Device&, inexor::vulkan_renderer::wrapper::CpuTexture&) /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/alloc_traits.h:514:4
    #9 0x7d8a67 in void std::vector<inexor::vulkan_renderer::wrapper::GpuTexture, std::allocator<inexor::vulkan_renderer::wrapper::GpuTexture> >::_M_realloc_insert<inexor::vulkan_renderer::wrapper::Device&, inexor::vulkan_renderer::wrapper::CpuTexture&>(__gnu_cxx::__normal_iterator<inexor::vulkan_renderer::wrapper::GpuTexture*, std::vector<inexor::vulkan_renderer::wrapper::GpuTexture, std::allocator<inexor::vulkan_renderer::wrapper::GpuTexture> > >, inexor::vulkan_renderer::wrapper::Device&, inexor::vulkan_renderer::wrapper::CpuTexture&) /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/vector.tcc:449:4
    #10 0x5167a1 in inexor::vulkan_renderer::wrapper::GpuTexture& std::vector<inexor::vulkan_renderer::wrapper::GpuTexture, std::allocator<inexor::vulkan_renderer::wrapper::GpuTexture> >::emplace_back<inexor::vulkan_renderer::wrapper::Device&, inexor::vulkan_renderer::wrapper::CpuTexture&>(inexor::vulkan_renderer::wrapper::Device&, inexor::vulkan_renderer::wrapper::CpuTexture&) /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/vector.tcc:121:4
    #11 0x50152f in inexor::vulkan_renderer::Application::load_textures() /home/johannes/Inexor/vulkan-renderer/src/vulkan-renderer/application.cpp:150:20
    #12 0x50987f in inexor::vulkan_renderer::Application::Application(int, char**) /home/johannes/Inexor/vulkan-renderer/src/vulkan-renderer/application.cpp:483:5
    #13 0x4d9d3c in std::_MakeUniq<inexor::vulkan_renderer::Application>::__single_object std::make_unique<inexor::vulkan_renderer::Application, int&, char**&>(int&, char**&) /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/unique_ptr.h:962:34
    #14 0x4d7801 in main /home/johannes/Inexor/vulkan-renderer/example/main.cpp:30:20
    #15 0x7f5657f6b0b2 in __libc_start_main /build/glibc-sMfBJT/glibc-2.31/csu/../csu/libc-start.c:308:16
    #16 0x42c3bd in _start (/home/johannes/Inexor/vulkan-renderer/build/bin/inexor-vulkan-renderer-example+0x42c3bd)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/johannes/.conan/data/vulkan-memory-allocator/2.3.0/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/vk_mem_alloc.h:15186:9 in VmaAllocator_T::GetBufferMemoryRequirements(VkBuffer_T*, VkMemoryRequirements&, bool&, bool&) const
==8506==ABORTING
IAmNotHanni commented 2 years ago

Running valgrind 3.15.0 yields:

==12854== Jump to the invalid address stated on the next line
==12854==    at 0x0: ???
==12854==    by 0x53F524: vmaCreateBuffer (.conan/data/vulkan-memory-allocator/2.3.0/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/vk_mem_alloc.h:17508)
==12854==    by 0x57ADBB: inexor::vulkan_renderer::wrapper::GPUMemoryBuffer::GPUMemoryBuffer(inexor::vulkan_renderer::wrapper::Device const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long const&, unsigned int const&, VmaMemoryUsage const&) (src/vulkan-renderer/wrapper/gpu_memory_buffer.cpp:41)
==12854==    by 0x57AF6E: inexor::vulkan_renderer::wrapper::GPUMemoryBuffer::GPUMemoryBuffer(inexor::vulkan_renderer::wrapper::Device const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long const&, void*, unsigned long, unsigned int const&, VmaMemoryUsage const&) (src/vulkan-renderer/wrapper/gpu_memory_buffer.cpp:54)
==12854==    by 0x55D986: inexor::vulkan_renderer::wrapper::StagingBuffer::StagingBuffer(inexor::vulkan_renderer::wrapper::Device const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, void*, unsigned long) (src/vulkan-renderer/wrapper/staging_buffer.cpp:13)
==12854==    by 0x555641: inexor::vulkan_renderer::wrapper::GpuTexture::create_texture(void*, unsigned long) (src/vulkan-renderer/wrapper/gpu_texture.cpp:50)
==12854==    by 0x555561: inexor::vulkan_renderer::wrapper::GpuTexture::GpuTexture(inexor::vulkan_renderer::wrapper::Device const&, inexor::vulkan_renderer::wrapper::CpuTexture const&) (src/vulkan-renderer/wrapper/gpu_texture.cpp:20)
==12854==    by 0x4B4031: _ZSt12construct_atIN6inexor15vulkan_renderer7wrapper10GpuTextureEJRNS2_6DeviceERNS2_10CpuTextureEEEDTgsnwcvPvLi0E_T_pispclsr3stdE7declvalIT0_EEEEPS9_DpOSA_ (stl_construct.h:97)
==12854==    by 0x4B3C88: void std::allocator_traits<std::allocator<inexor::vulkan_renderer::wrapper::GpuTexture> >::construct<inexor::vulkan_renderer::wrapper::GpuTexture, inexor::vulkan_renderer::wrapper::Device&, inexor::vulkan_renderer::wrapper::CpuTexture&>(std::allocator<inexor::vulkan_renderer::wrapper::GpuTexture>&, inexor::vulkan_renderer::wrapper::GpuTexture*, inexor::vulkan_renderer::wrapper::Device&, inexor::vulkan_renderer::wrapper::CpuTexture&) (alloc_traits.h:514)
==12854==    by 0x4B3D72: void std::vector<inexor::vulkan_renderer::wrapper::GpuTexture, std::allocator<inexor::vulkan_renderer::wrapper::GpuTexture> >::_M_realloc_insert<inexor::vulkan_renderer::wrapper::Device&, inexor::vulkan_renderer::wrapper::CpuTexture&>(__gnu_cxx::__normal_iterator<inexor::vulkan_renderer::wrapper::GpuTexture*, std::vector<inexor::vulkan_renderer::wrapper::GpuTexture, std::allocator<inexor::vulkan_renderer::wrapper::GpuTexture> > >, inexor::vulkan_renderer::wrapper::Device&, inexor::vulkan_renderer::wrapper::CpuTexture&) (vector.tcc:449)
==12854==    by 0x41C626: inexor::vulkan_renderer::wrapper::GpuTexture& std::vector<inexor::vulkan_renderer::wrapper::GpuTexture, std::allocator<inexor::vulkan_renderer::wrapper::GpuTexture> >::emplace_back<inexor::vulkan_renderer::wrapper::Device&, inexor::vulkan_renderer::wrapper::CpuTexture&>(inexor::vulkan_renderer::wrapper::Device&, inexor::vulkan_renderer::wrapper::CpuTexture&) (vector.tcc:121)
==12854==    by 0x41812A: inexor::vulkan_renderer::Application::load_textures() (src/vulkan-renderer/application.cpp:150)
==12854==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==12854== 
==12854== 
==12854== Process terminating with default action of signal 11 (SIGSEGV)
==12854==  Bad permissions for mapped region at address 0x0
==12854==    at 0x0: ???
==12854==    by 0x53F524: vmaCreateBuffer (.conan/data/vulkan-memory-allocator/2.3.0/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/vk_mem_alloc.h:17508)
==12854==    by 0x57ADBB: inexor::vulkan_renderer::wrapper::GPUMemoryBuffer::GPUMemoryBuffer(inexor::vulkan_renderer::wrapper::Device const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long const&, unsigned int const&, VmaMemoryUsage const&) (src/vulkan-renderer/wrapper/gpu_memory_buffer.cpp:41)
==12854==    by 0x57AF6E: inexor::vulkan_renderer::wrapper::GPUMemoryBuffer::GPUMemoryBuffer(inexor::vulkan_renderer::wrapper::Device const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long const&, void*, unsigned long, unsigned int const&, VmaMemoryUsage const&) (src/vulkan-renderer/wrapper/gpu_memory_buffer.cpp:54)
==12854==    by 0x55D986: inexor::vulkan_renderer::wrapper::StagingBuffer::StagingBuffer(inexor::vulkan_renderer::wrapper::Device const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, void*, unsigned long) (src/vulkan-renderer/wrapper/staging_buffer.cpp:13)
==12854==    by 0x555641: inexor::vulkan_renderer::wrapper::GpuTexture::create_texture(void*, unsigned long) (src/vulkan-renderer/wrapper/gpu_texture.cpp:50)
==12854==    by 0x555561: inexor::vulkan_renderer::wrapper::GpuTexture::GpuTexture(inexor::vulkan_renderer::wrapper::Device const&, inexor::vulkan_renderer::wrapper::CpuTexture const&) (src/vulkan-renderer/wrapper/gpu_texture.cpp:20)
==12854==    by 0x4B4031: _ZSt12construct_atIN6inexor15vulkan_renderer7wrapper10GpuTextureEJRNS2_6DeviceERNS2_10CpuTextureEEEDTgsnwcvPvLi0E_T_pispclsr3stdE7declvalIT0_EEEEPS9_DpOSA_ (stl_construct.h:97)
==12854==    by 0x4B3C88: void std::allocator_traits<std::allocator<inexor::vulkan_renderer::wrapper::GpuTexture> >::construct<inexor::vulkan_renderer::wrapper::GpuTexture, inexor::vulkan_renderer::wrapper::Device&, inexor::vulkan_renderer::wrapper::CpuTexture&>(std::allocator<inexor::vulkan_renderer::wrapper::GpuTexture>&, inexor::vulkan_renderer::wrapper::GpuTexture*, inexor::vulkan_renderer::wrapper::Device&, inexor::vulkan_renderer::wrapper::CpuTexture&) (alloc_traits.h:514)
==12854==    by 0x4B3D72: void std::vector<inexor::vulkan_renderer::wrapper::GpuTexture, std::allocator<inexor::vulkan_renderer::wrapper::GpuTexture> >::_M_realloc_insert<inexor::vulkan_renderer::wrapper::Device&, inexor::vulkan_renderer::wrapper::CpuTexture&>(__gnu_cxx::__normal_iterator<inexor::vulkan_renderer::wrapper::GpuTexture*, std::vector<inexor::vulkan_renderer::wrapper::GpuTexture, std::allocator<inexor::vulkan_renderer::wrapper::GpuTexture> > >, inexor::vulkan_renderer::wrapper::Device&, inexor::vulkan_renderer::wrapper::CpuTexture&) (vector.tcc:449)
==12854==    by 0x41C626: inexor::vulkan_renderer::wrapper::GpuTexture& std::vector<inexor::vulkan_renderer::wrapper::GpuTexture, std::allocator<inexor::vulkan_renderer::wrapper::GpuTexture> >::emplace_back<inexor::vulkan_renderer::wrapper::Device&, inexor::vulkan_renderer::wrapper::CpuTexture&>(inexor::vulkan_renderer::wrapper::Device&, inexor::vulkan_renderer::wrapper::CpuTexture&) (vector.tcc:121)
==12854==    by 0x41812A: inexor::vulkan_renderer::Application::load_textures() (src/vulkan-renderer/application.cpp:150)
==12854== 
==12854== HEAP SUMMARY:
==12854==     in use at exit: 23,203,407 bytes in 47,899 blocks
==12854==   total heap usage: 128,951 allocs, 81,052 frees, 1,509,946,853 bytes allocated
==12854== 
==12854== LEAK SUMMARY:
==12854==    definitely lost: 152 bytes in 5 blocks
==12854==    indirectly lost: 24 bytes in 1 blocks
==12854==      possibly lost: 424,485 bytes in 1,875 blocks
==12854==    still reachable: 22,778,746 bytes in 46,018 blocks
==12854==                       of which reachable via heuristic:
==12854==                         newarray           : 16 bytes in 1 blocks
==12854==                         multipleinheritance: 104 bytes in 1 blocks
==12854==         suppressed: 0 bytes in 0 blocks
==12854== Rerun with --leak-check=full to see details of leaked memory
==12854== 
==12854== For lists of detected and suppressed errors, rerun with: -s
==12854== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 2 from 2)
IAmNotHanni commented 2 years ago

Interestingly, PFN_vkGetImageMemoryRequirements2KHR is a null pointer for some reason. I used gdb to find out:

grafik

IAmNotHanni commented 2 years ago

I did sudo apt install nvidia-driver-510 on my Linux and now it works. I still don't understand why VMA did not validate the function pointer, but since version 2.3.0 is quite outdated (and so is my graphics card: NVidia GTX 660M), it's probably not worth to dig deeper into it.