Closed polarina closed 6 years ago
The safe_* structs are allocated using C++'s new allocator in CreateUnwrappedExtensionStructs, but were freed using free().
safe_*
new
CreateUnwrappedExtensionStructs
This mismatch is undefined behavior.
Fix by having FreeUnwrappedExtensionStructs call delete on the correct safe class.
FreeUnwrappedExtensionStructs
delete
Note: Google Test filter = *DedicatedAllocation* [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from VkLayerTest [ RUN ] VkLayerTest.DedicatedAllocation ================================================================= ==18347==ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new vs free) on 0x6030001f58b0 #0 0x7f0fe4a058c8 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xd98c8) #1 0x7f0fcaa17221 in unique_objects::FreeUnwrappedExtensionStructs(void*) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/build/layers/unique_objects_wrappers.h:288 #2 0x7f0fcaa18094 in unique_objects::AllocateMemory(VkDevice_T*, VkMemoryAllocateInfo const*, VkAllocationCallbacks const*, VkDeviceMemory_T**) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/build/layers/unique_objects_wrappers.h:400 #3 0x7f0fc874ad69 in core_validation::AllocateMemory(VkDevice_T*, VkMemoryAllocateInfo const*, VkAllocationCallbacks const*, VkDeviceMemory_T**) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/layers/core_validation.cpp:3012 #4 0x7f0fc70193b5 in object_tracker::AllocateMemory(VkDevice_T*, VkMemoryAllocateInfo const*, VkAllocationCallbacks const*, VkDeviceMemory_T**) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/build/layers/object_tracker.cpp:301 #5 0x7f0fc5fddf12 in parameter_validation::vkAllocateMemory(VkDevice_T*, VkMemoryAllocateInfo const*, VkAllocationCallbacks const*, VkDeviceMemory_T**) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/build/layers/parameter_validation.cpp:1426 #6 0x7f0fc53291e4 in threading::AllocateMemory(VkDevice_T*, VkMemoryAllocateInfo const*, VkAllocationCallbacks const*, VkDeviceMemory_T**) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/build/layers/thread_check.h:228 #7 0x7f0fe45cf95d in vkAllocateMemory /home/polarina/projects/Vulkan-LoaderAndValidationLayers/loader/trampoline.c:1035 #8 0x56214be7edbe in vk_testing::DeviceMemory::init(vk_testing::Device const&, VkMemoryAllocateInfo const&) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/vktestbinding.cpp:415 #9 0x56214bcfc374 in VkLayerTest_DedicatedAllocation_Test::TestBody() /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/layer_validation_tests.cpp:26196 #10 0x7f0fe3011beb in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:2078 #11 0x7f0fe2fff391 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:2114 #12 0x7f0fe2fa2c53 in testing::Test::Run() /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:2150 #13 0x7f0fe2fa4948 in testing::TestInfo::Run() /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:2326 #14 0x7f0fe2fa5f03 in testing::TestCase::Run() /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:2444 #15 0x7f0fe2fbe33d in testing::internal::UnitTestImpl::RunAllTests() /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:4311 #16 0x7f0fe30163db in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:2078 #17 0x7f0fe3002f07 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:2114 #18 0x7f0fe2fb94cf in testing::UnitTest::Run() /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:3922 #19 0x56214bd502b4 in RUN_ALL_TESTS() (/home/polarina/projects/Vulkan-LoaderAndValidationLayers/build/tests/vk_layer_validation_tests+0x9df2b4) #20 0x56214bd2a817 in main /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/layer_validation_tests.cpp:27913 #21 0x7f0fe14b3a86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21a86) #22 0x56214b9b7cb9 in _start (/home/polarina/projects/Vulkan-LoaderAndValidationLayers/build/tests/vk_layer_validation_tests+0x646cb9) 0x6030001f58b0 is located 0 bytes inside of 32-byte region [0x6030001f58b0,0x6030001f58d0) allocated by thread T0 here: #0 0x7f0fe4a07340 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdb340) #1 0x7f0fcaa16415 in unique_objects::CreateUnwrappedExtensionStructs(void const*) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/build/layers/unique_objects_wrappers.h:167 #2 0x7f0fcaa17f20 in unique_objects::AllocateMemory(VkDevice_T*, VkMemoryAllocateInfo const*, VkAllocationCallbacks const*, VkDeviceMemory_T**) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/build/layers/unique_objects_wrappers.h:395 #3 0x7f0fc874ad69 in core_validation::AllocateMemory(VkDevice_T*, VkMemoryAllocateInfo const*, VkAllocationCallbacks const*, VkDeviceMemory_T**) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/layers/core_validation.cpp:3012 #4 0x7f0fc70193b5 in object_tracker::AllocateMemory(VkDevice_T*, VkMemoryAllocateInfo const*, VkAllocationCallbacks const*, VkDeviceMemory_T**) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/build/layers/object_tracker.cpp:301 #5 0x7f0fc5fddf12 in parameter_validation::vkAllocateMemory(VkDevice_T*, VkMemoryAllocateInfo const*, VkAllocationCallbacks const*, VkDeviceMemory_T**) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/build/layers/parameter_validation.cpp:1426 #6 0x7f0fc53291e4 in threading::AllocateMemory(VkDevice_T*, VkMemoryAllocateInfo const*, VkAllocationCallbacks const*, VkDeviceMemory_T**) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/build/layers/thread_check.h:228 #7 0x7f0fe45cf95d in vkAllocateMemory /home/polarina/projects/Vulkan-LoaderAndValidationLayers/loader/trampoline.c:1035 #8 0x56214be7edbe in vk_testing::DeviceMemory::init(vk_testing::Device const&, VkMemoryAllocateInfo const&) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/vktestbinding.cpp:415 #9 0x56214bcfc374 in VkLayerTest_DedicatedAllocation_Test::TestBody() /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/layer_validation_tests.cpp:26196 #10 0x7f0fe3011beb in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:2078 #11 0x7f0fe2fff391 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:2114 #12 0x7f0fe2fa2c53 in testing::Test::Run() /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:2150 #13 0x7f0fe2fa4948 in testing::TestInfo::Run() /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:2326 #14 0x7f0fe2fa5f03 in testing::TestCase::Run() /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:2444 #15 0x7f0fe2fbe33d in testing::internal::UnitTestImpl::RunAllTests() /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:4311 #16 0x7f0fe30163db in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:2078 #17 0x7f0fe3002f07 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:2114 #18 0x7f0fe2fb94cf in testing::UnitTest::Run() /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/gtest-1.7.0/src/gtest.cc:3922 #19 0x56214bd502b4 in RUN_ALL_TESTS() (/home/polarina/projects/Vulkan-LoaderAndValidationLayers/build/tests/vk_layer_validation_tests+0x9df2b4) #20 0x56214bd2a817 in main /home/polarina/projects/Vulkan-LoaderAndValidationLayers/tests/layer_validation_tests.cpp:27913 #21 0x7f0fe14b3a86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21a86) SUMMARY: AddressSanitizer: alloc-dealloc-mismatch (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xd98c8) in __interceptor_free ==18347==HINT: if you don't care about these errors you may set ASAN_OPTIONS=alloc_dealloc_mismatch=0 ==18347==ABORTING
The
safe_*
structs are allocated using C++'snew
allocator inCreateUnwrappedExtensionStructs
, but were freed using free().This mismatch is undefined behavior.
Fix by having
FreeUnwrappedExtensionStructs
calldelete
on the correct safe class.