Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vulkan] The VK_LAYER_KHRONOS_validation causes a crash on exit if loaded #8290

Closed
derek-gerstmann opened this issue Jun 13, 2024 · 1 comment
Assignees

Comments

@derek-gerstmann
Copy link
Contributor

When the VK_LAYER_KHRONOS_validation is intercepting calls to the API, it will cause a segfault if it's invoked inside the destructor due to an uncaught exception for an invalid mutex lock.

libc++abi: terminating with uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument

> VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ./build/test/generator/generator_aot_alias    
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00000001a431ad38 libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x00000001a434fee0 libsystem_pthread.dylib`pthread_kill + 288
    frame #2: 0x00000001a428a330 libsystem_c.dylib`abort + 168
    frame #3: 0x00000001a430ab18 libc++abi.dylib`abort_message + 132
    frame #4: 0x00000001a42faa3c libc++abi.dylib`demangling_terminate_handler() + 312
    frame #5: 0x00000001a41f01c8 libobjc.A.dylib`_objc_terminate() + 160
    frame #6: 0x00000001a4309eb4 libc++abi.dylib`std::__terminate(void (*)()) + 20
    frame #7: 0x00000001a430cc2c libc++abi.dylib`__cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 36
    frame #8: 0x00000001a430cbd8 libc++abi.dylib`__cxa_throw + 140
    frame #9: 0x00000001a42ab9a4 libc++.1.dylib`std::__1::__throw_system_error(int, char const*) + 100
    frame #10: 0x00000001a42a11d0 libc++.1.dylib`std::__1::mutex::lock() + 40
    frame #11: 0x0000000113eb01b0 libVkLayer_khronos_validation.dylib`vl_concurrent_unordered_map<unsigned long long, unsigned long long, 4, HashedUint64>::find(unsigned long long const&) const + 60
    frame #12: 0x0000000113eb77ec libVkLayer_khronos_validation.dylib`DispatchResetCommandPool(VkDevice_T*, VkCommandPool_T*, unsigned int) + 88
    frame #13: 0x0000000113e08978 libVkLayer_khronos_validation.dylib`vulkan_layer_chassis::ResetCommandPool(VkDevice_T*, VkCommandPool_T*, unsigned int) + 284
    frame #14: 0x0000000100019054 generator_aot_alias`halide_vulkan_device_release + 456
    frame #15: 0x000000010002d824 generator_aot_alias`___lldb_unnamed_symbol3872 + 8
    frame #16: 0x00000001a423bdc0 libsystem_c.dylib`__cxa_finalize_ranges + 464
    frame #17: 0x00000001a423bb64 libsystem_c.dylib`exit + 44
    frame #18: 0x00000001a435cec4 libdyld.dylib`dyld4::LibSystemHelpers::exit(int) const + 20
    frame #19: 0x00000001000850d8 dyld`start + 596
derek-gerstmann pushed a commit that referenced this issue Jun 13, 2024
destructor which calls halide_vulkan_device_release() to avoid a
segfault (at the cost of leaking!).  See
#8290.

Refactor and cleanup halide_vulkan_device_release().
Add vk_destroy_context() methods.
@derek-gerstmann derek-gerstmann self-assigned this Jun 14, 2024
abadams added a commit that referenced this issue Jun 23, 2024
…er crash on exit. (#8289)

* Remove the compile-time link dependency for the Vulkan loader, and resolve the instance methods dynamically.
Update the Vulkan readme to match the latest information regarding the SDK packages.

* Formatting pass.w

* Add runtime check to verify shared memory amount used in pipeline can be run on device

* Fix platform ifdefs for Vulkan library names (normal ones arent defined
when the runtime is compiled).

* Detect if VK_LAYER_KHRONOS_validation is enabled, and bypass the module
destructor which calls halide_vulkan_device_release() to avoid a
segfault (at the cost of leaking!).  See
#8290.

Refactor and cleanup halide_vulkan_device_release().
Add vk_destroy_context() methods.

* Fix GPU object lifetime AOT test to use TEST_VULKAN macro.

* Fix clang tidy warning for usage of static in anonymous namespace

* Disable Vulkan validation layer for leak tests (or we'll leak).

* Add vk_validate_shader_for_device() method to check shader bindings
against device limits prior to compiling to verify shader compatibility.

---------

Co-authored-by: Derek Gerstmann <dgerstmann@adobe.com>
Co-authored-by: Andrew Adams <andrew.b.adams@gmail.com>
@derek-gerstmann
Copy link
Contributor Author

Fixed in newer versions of the Vulkan SDK. Tested against v1.3.296.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant