Freeze on vkDestroyDevice in libnvidia-glcore.so

Whenever an application calls vkDestroyDevice, it will freeze. It affect vulkaninfo, steam, games, vkcube, everything.

Arch Linux on X11
Driver: 495.44 from package nvidia-dkms
GeForce 1070 GTX

Backtrace from debugging:

#0 0x00007ffff79bb8ca in __futex_abstimed_wait_common64 () from /usr/lib/libpthread.so.0
#1 0x00007ffff79b0743 in __pthread_clockjoin_ex () from /usr/lib/libpthread.so.0
#2 0x00007ffff5d5ed08 in ?? () from /usr/lib/libnvidia-glcore.so.495.44
#3 0x00007ffff61d3ca0 in ?? () from /usr/lib/libnvidia-glcore.so.495.44
#4 0x00007ffff619b315 in ?? () from /usr/lib/libnvidia-glcore.so.495.44
#5 0x00007ffff770ae8f in ?? () from /usr/lib/libGLX_nvidia.so.0
#6 0x00007ffff7f410aa in ?? () from /usr/lib/libvulkan.so.1
#7 0x00007ffff7f4ba78 in vkDestroyDevice () from /usr/lib/libvulkan.so.1
#8 0x0000555555558366 in main () at /home/elrick/Projects/Dumpster/TestVulkan/main.cpp:448

I had to run nvidia-bug-report.sh --safe-mode or it would also freeze:
nvidia-bug-report.log.gz (137.2 KB)

I traced the problem to using __GL_THREADED_OPTIMIZATIONS. I guess it’s not a good idea to blanket enable that everywhere.

Please see:
https://forums.developer.nvidia.com/t/495-x-regression-vulkan-applications-hang-indefinitely/194378/5