vsg-dev / VulkanSceneGraph

Vulkan & C++17 based Scene Graph Project
http://www.vulkanscenegraph.org
MIT License
1.32k stars 212 forks source link

Data race #147

Closed nsajko closed 4 years ago

nsajko commented 4 years ago

Describe the bug Thread sanitizer report:

WARNING: ThreadSanitizer: data race (pid=15143)
  Write of size 1 at 0x7ffd347759c0 by main thread (mutexes: write M9):
    #0 pthread_barrier_destroy /build/gcc/src/gcc/libsanitizer/tsan/tsan_interceptors.cc:1369 (libtsan.so.0+0x2f4fd)
    #1 <null> <null> (libvulkan_intel.so+0x32b578)
    #2 vsg::Instance::~Instance() /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/src/vsg/vk/Instance.cpp:71 (a.out+0xd548d)
    #3 vsg::Object::_attemptDelete() const /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/src/vsg/core/Object.cpp:107 (a.out+0x68c6a)
    #4 vsg::Object::unref() const /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/include/vsg/core/Object.h:71 (a.out+0xbdf9a)
    #5 vsg::ref_ptr<vsg::Instance>::~ref_ptr() /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/include/vsg/core/ref_ptr.h:53 (a.out+0xbdf9a)
    #6 vsg::Device::~Device() /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/src/vsg/vk/Device.cpp:62 (a.out+0xbdf9a)
    #7 vsg::Device::~Device() /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/src/vsg/vk/Device.cpp:71 (a.out+0xbe00d)
    #8 vsg::Object::_attemptDelete() const /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/src/vsg/core/Object.cpp:107 (a.out+0x68c6a)
    #9 vsg::Object::unref() const /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/include/vsg/core/Object.h:71 (a.out+0xfdf72)
    #10 vsg::ref_ptr<vsg::Device>::~ref_ptr() /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/include/vsg/core/ref_ptr.h:53 (a.out+0xfdf72)
    #11 vsg::ShaderModule::Implementation::~Implementation() /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/src/vsg/vk/ShaderModule.cpp:96 (a.out+0xfdf72)
    #12 vsg::ShaderModule::Implementation::~Implementation() /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/src/vsg/vk/ShaderModule.cpp:99 (a.out+0xfdfbd)
    #13 vsg::Object::_attemptDelete() const /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/src/vsg/core/Object.cpp:107 (a.out+0x68c6a)
    #14 vsg::Object::unref() const /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/include/vsg/core/Object.h:71 (a.out+0xfddea)
    #15 vsg::ref_ptr<vsg::ShaderModule::Implementation>::~ref_ptr() /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/include/vsg/core/ref_ptr.h:53 (a.out+0xfddea)
    #16 vsg::vk_buffer<vsg::ref_ptr<vsg::ShaderModule::Implementation> >::~vk_buffer() /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/include/vsg/vk/vk_buffer.h:27 (a.out+0xfddea)
    #17 vsg::ShaderModule::~ShaderModule() /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/src/vsg/vk/ShaderModule.cpp:42 (a.out+0xfddea)
    #18 vsg::ShaderModule::~ShaderModule() /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/src/vsg/vk/ShaderModule.cpp:44 (a.out+0xfde0d)
    #19 vsg::Object::_attemptDelete() const /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/src/vsg/core/Object.cpp:107 (a.out+0x68c6a)
    #20 vsg::Object::unref() const /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/include/vsg/core/Object.h:71 (a.out+0xe587a)
    #21 vsg::ref_ptr<vsg::ShaderModule>::~ref_ptr() /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/include/vsg/core/ref_ptr.h:53 (a.out+0xe587a)
    #22 vsg::ShaderStage::~ShaderStage() /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/include/vsg/vk/ShaderStage.h:23 (a.out+0xe587a)
    #23 vsg::ShaderStage::~ShaderStage() /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/include/vsg/vk/ShaderStage.h:23 (a.out+0xe587a)
    #24 vsg::Object::_attemptDelete() const /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/src/vsg/core/Object.cpp:107 (a.out+0x68c6a)
    #25 vsg::Object::unref() const /usr/local/include/vsg/core/Object.h:71 (a.out+0x47bb2)
    #26 vsg::ref_ptr<vsg::ShaderStage>::~ref_ptr() /usr/local/include/vsg/core/ref_ptr.h:53 (a.out+0x4e5cc)
    #27 main /home/nsajko/graphicsSrc/vsg-dev/vsgExamples/Desktop/vsgdraw/vsgdraw.cpp:17 (a.out+0x46f07)

  Previous read of size 1 at 0x7ffd347759c0 by thread T3:
    #0 pthread_barrier_wait /build/gcc/src/gcc/libsanitizer/tsan/tsan_interceptors.cc:1376 (libtsan.so.0+0x2f61f)
    #1 <null> <null> (libvulkan_intel.so+0x32aadb)

  Location is stack of main thread.

  Location is global '<null>' at 0x000000000000 ([stack]+0x00000001f9c0)

  Mutex M9 (0x7f6bf44c10c0) created at:
    #0 pthread_mutex_init /build/gcc/src/gcc/libsanitizer/tsan/tsan_interceptors.cc:1183 (libtsan.so.0+0x2df92)
    #1 <null> <null> (libvulkan.so.1+0x2b4bc)

  Thread T3 'a.out:disk$2' (tid=15147, running) created by main thread at:
    #0 pthread_create /build/gcc/src/gcc/libsanitizer/tsan/tsan_interceptors.cc:964 (libtsan.so.0+0x2d683)
    #1 <null> <null> (libvulkan_intel.so+0x32a87b)
    #2 vsg::Window::Window(vsg::ref_ptr<vsg::WindowTraits>, vsg::AllocationCallbacks*) /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/src/vsg/viewer/Window.cpp:49 (a.out+0x95ffc)
    #3 vsgXcb::Xcb_Window::Xcb_Window(vsg::ref_ptr<vsg::WindowTraits>, vsg::AllocationCallbacks*) /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/src/vsg/platform/unix/Xcb_Window.cpp:263 (a.out+0xea527)
    #4 vsgXcb::Xcb_Window::create(vsg::ref_ptr<vsg::WindowTraits>, vsg::AllocationCallbacks*) /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/src/vsg/platform/unix/Xcb_Window.cpp:253 (a.out+0xeb6dd)
    #5 vsg::Window::create(vsg::ref_ptr<vsg::WindowTraits>) /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/src/vsg/platform/unix/Xcb_Window.cpp:33 (a.out+0xeb8d7)
    #6 vsg::Window::create(unsigned int, unsigned int, bool, bool, vsg::Window*, vsg::AllocationCallbacks*) /home/nsajko/graphicsSrc/vsg-dev/VulkanSceneGraph/src/vsg/viewer/Window.cpp:239 (a.out+0x91610)
    #7 main /home/nsajko/graphicsSrc/vsg-dev/vsgExamples/Desktop/vsgdraw/vsgdraw.cpp:149 (a.out+0x46527)

SUMMARY: ThreadSanitizer: data race (/usr/lib/libvulkan_intel.so+0x32b578)

To Reproduce Steps to reproduce the behavior:

  1. Build vsg with thread sanitizer
  2. Build vsgdraw with thread sanitizer
  3. Run vsgdraw
  4. See error

Expected behavior There should be no data races, as even ones that may seem benign are an error in C++, as in C.

nsajko commented 4 years ago

Just tried vsgdraw with Nvidia instead of Intel, and there is no data race.

So this is probably an issue with the Intel Mesa driver rather than VSG.