yuzu icon indicating copy to clipboard operation
yuzu copied to clipboard

Race condition in VKScheduler

Open comex opened this issue 4 years ago • 4 comments

After running into some very mysterious crashes in CommandChunk::Record, I tried running Yuzu under ThreadSanitizer. I got the following report. Looks like there's some missing synchronization.

Yuzu version: 3a85bc1e771b8c11728b6535710e21dc092b6732 on macOS (with some WIP patches, but nothing that I'd expect to cause this) I'm running with use_asynchronous_gpu_emulation = 0; game is Super Mario Maker 2.

I tried locking mutex in Record and DispatchWork (which required modifying AllocateNewContext to avoid deadlock); I think this fixed the race, but I'm not sure if those are the right places to be adding locks (or how that might affect performance).

Possibly unrelated, but when using the Vulkan validation layer I'm also getting errors about vkCmdDrawIndexed being called while not in an active render pass.

Process 93712 resuming
==================
WARNING: ThreadSanitizer: data race (pid=93712)
  Read of size 8 at 0x7bb400050010 by thread T20 (mutexes: write M148472655736472024):
    #0 Vulkan::VKScheduler::CommandChunk::Empty() const vk_scheduler.h:151 (yuzu-cmd:x86_64+0x10124ff99)
    #1 Vulkan::VKScheduler::DispatchWork() vk_scheduler.cpp:91 (yuzu-cmd:x86_64+0x10124fe21)
    #2 Vulkan::VKScheduler::WaitWorker() vk_scheduler.cpp:80 (yuzu-cmd:x86_64+0x10124fcfb)
    #3 Vulkan::VKScheduler::SubmitExecution(VkSemaphore_T*) vk_scheduler.cpp:165 (yuzu-cmd:x86_64+0x10124f88f)
    #4 Vulkan::VKScheduler::Flush(VkSemaphore_T*) vk_scheduler.cpp:67 (yuzu-cmd:x86_64+0x10124f7df)
    #5 Vulkan::RendererVulkan::SwapBuffers(Tegra::FramebufferConfig const*) renderer_vulkan.cpp:291 (yuzu-cmd:x86_64+0x1010b0a1d)
    #6 VideoCommon::GPUSynch::SwapBuffers(Tegra::FramebufferConfig const*) gpu_synch.cpp:46 (yuzu-cmd:x86_64+0x100caf326)
    #7 Service::Nvidia::Devices::nvdisp_disp0::flip(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, Service::NVFlinger::BufferQueue::BufferTransformFlags, Common::Rectangle<int> const&) nvdisp_disp0.cpp:54 (yuzu-cmd:x86_64+0x100794331)
    #8 Service::NVFlinger::NVFlinger::Compose() nvflinger.cpp:266 (yuzu-cmd:x86_64+0x1007f54c9)
    #9 Service::NVFlinger::NVFlinger::SplitVSync() nvflinger.cpp:47 (yuzu-cmd:x86_64+0x1007f4b7f)
    #10 Service::NVFlinger::NVFlinger::VSyncThread(Service::NVFlinger::NVFlinger&) nvflinger.cpp:34 (yuzu-cmd:x86_64+0x1007f49d8)
    #11 decltype(std::__1::forward<void (*)(Service::NVFlinger::NVFlinger&)>(fp)(std::__1::forward<std::__1::reference_wrapper<Service::NVFlinger::NVFlinger> >(fp0))) std::__1::__invoke<void (*)(Service::NVFlinger::NVFlinger&), std::__1::reference_wrapper<Service::NVFlinger::NVFlinger> >(void (*&&)(Service::NVFlinger::NVFlinger&), std::__1::reference_wrapper<Service::NVFlinger::NVFlinger>&&) type_traits:3899 (yuzu-cmd:x86_64+0x100803585)
    #12 void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(Service::NVFlinger::NVFlinger&), std::__1::reference_wrapper<Service::NVFlinger::NVFlinger>, 2ul>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(Service::NVFlinger::NVFlinger&), std::__1::reference_wrapper<Service::NVFlinger::NVFlinger> >&, std::__1::__tuple_indices<2ul>) thread:280 (yuzu-cmd:x86_64+0x100803471)
    #13 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(Service::NVFlinger::NVFlinger&), std::__1::reference_wrapper<Service::NVFlinger::NVFlinger> > >(void*) thread:291 (yuzu-cmd:x86_64+0x100802c99)

  Previous write of size 8 at 0x7bb400050010 by thread T13:
    #0 bool Vulkan::VKScheduler::CommandChunk::Record<Vulkan::VKImage::Transition(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, VkImageLayout)::$_1>(Vulkan::VKImage::Transition(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, VkImageLayout)::$_1&) vk_scheduler.h:146 (yuzu-cmd:x86_64+0x1011256de)
    #1 void Vulkan::VKScheduler::Record<Vulkan::VKImage::Transition(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, VkImageLayout)::$_1>(Vulkan::VKImage::Transition(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, VkImageLayout)::$_1&&) vk_scheduler.h:74 (yuzu-cmd:x86_64+0x10111fda0)
    #2 Vulkan::VKImage::Transition(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, VkImageLayout) vk_image.cpp:67 (yuzu-cmd:x86_64+0x10111f8ec)
    #3 Vulkan::CachedSurface::Transition(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, VkImageLayout) vk_texture_cache.h:60 (yuzu-cmd:x86_64+0x1011c644b)
    #4 Vulkan::CachedSurfaceView::Transition(VkImageLayout, unsigned int, unsigned int) const vk_texture_cache.h:162 (yuzu-cmd:x86_64+0x101171161)
    #5 Vulkan::RasterizerVulkan::SetupImageTransitions(std::__1::bitset<9ul>, std::__1::array<std::__1::shared_ptr<Vulkan::CachedSurfaceView>, 8ul> const&, std::__1::shared_ptr<Vulkan::CachedSurfaceView> const&) vk_rasterizer.cpp:921 (yuzu-cmd:x86_64+0x1011655ff)
    #6 Vulkan::RasterizerVulkan::Draw(bool, bool) vk_rasterizer.cpp:441 (yuzu-cmd:x86_64+0x101163d6e)
    #7 Tegra::Engines::Maxwell3D::FlushMMEInlineDraw() maxwell_3d.cpp:373 (yuzu-cmd:x86_64+0x100c4d56f)
    #8 Tegra::Engines::Maxwell3D::CallMacroMethod(unsigned int, std::__1::vector<unsigned int, std::__1::allocator<unsigned int> > const&) maxwell_3d.cpp:244 (yuzu-cmd:x86_64+0x100c4b717)
    #9 Tegra::Engines::Maxwell3D::ProcessMacro(unsigned int, unsigned int const*, unsigned int, bool) maxwell_3d.cpp:139 (yuzu-cmd:x86_64+0x100c4b14b)
    #10 Tegra::Engines::Maxwell3D::CallMultiMethod(unsigned int, unsigned int const*, unsigned int, unsigned int) maxwell_3d.cpp:283 (yuzu-cmd:x86_64+0x100c4de2b)
    #11 non-virtual thunk to Tegra::Engines::Maxwell3D::CallMultiMethod(unsigned int, unsigned int const*, unsigned int, unsigned int) maxwell_3d.cpp (yuzu-cmd:x86_64+0x100c4e2e4)
    #12 Tegra::DmaPusher::CallMultiMethod(unsigned int const*, unsigned int) const dma_pusher.cpp:167 (yuzu-cmd:x86_64+0x100c400b1)
    #13 Tegra::DmaPusher::Step() dma_pusher.cpp:93 (yuzu-cmd:x86_64+0x100c3f6e4)
    #14 Tegra::DmaPusher::DispatchCalls() dma_pusher.cpp:34 (yuzu-cmd:x86_64+0x100c3f0e5)
    #15 VideoCommon::GPUSynch::PushGPUEntries(Tegra::CommandList&&) gpu_synch.cpp:26 (yuzu-cmd:x86_64+0x100caec4d)
    #16 Service::Nvidia::Devices::nvhost_gpu::SubmitGPFIFOImpl(Service::Nvidia::Devices::nvhost_gpu::IoctlSubmitGpfifo&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >&, Tegra::CommandList&&) nvhost_gpu.cpp:242 (yuzu-cmd:x86_64+0x1007a7765)
    #17 Service::Nvidia::Devices::nvhost_gpu::SubmitGPFIFOBase(std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >&) nvhost_gpu.cpp:290 (yuzu-cmd:x86_64+0x1007a6d98)
    #18 Service::Nvidia::Devices::nvhost_gpu::Ioctl2(Service::Nvidia::Ioctl, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >&) nvhost_gpu.cpp:83 (yuzu-cmd:x86_64+0x1007a6bd3)
    #19 Service::Nvidia::Module::Ioctl2(int, Service::Nvidia::Ioctl, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >&) nvdrv.cpp:124 (yuzu-cmd:x86_64+0x1007cdf95)
    #20 Service::Nvidia::NVDRV::Ioctl2(Kernel::HLERequestContext&) <null>:2 (yuzu-cmd:x86_64+0x1007c758c)
    #21 Service::ServiceFramework<Service::Nvidia::NVDRV>::Invoker(Service::ServiceFrameworkBase*, void (Service::ServiceFrameworkBase::*)(Kernel::HLERequestContext&), Kernel::HLERequestContext&) <null>:2 (yuzu-cmd:x86_64+0x1007c9630)
    #22 Service::ServiceFrameworkBase::InvokeRequest(Kernel::HLERequestContext&) service.cpp:162 (yuzu-cmd:x86_64+0x10084125e)
    #23 Service::ServiceFrameworkBase::HandleSyncRequest(Kernel::HLERequestContext&) service.cpp:179 (yuzu-cmd:x86_64+0x100841b4b)
    #24 Kernel::ServerSession::CompleteSyncRequest() server_session.cpp:163 (yuzu-cmd:x86_64+0x1003e5e23)
    #25 Kernel::ServerSession::Create(Kernel::KernelCore&, std::__1::shared_ptr<Kernel::Session>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::$_0::operator()(unsigned long, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >) const server_session.cpp:37 (yuzu-cmd:x86_64+0x1003ec818)
    #26 decltype(std::__1::forward<Kernel::ServerSession::Create(Kernel::KernelCore&, std::__1::shared_ptr<Kernel::Session>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::$_0&>(fp)(std::__1::forward<unsigned long>(fp0), std::__1::forward<std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >(fp0))) std::__1::__invoke<Kernel::ServerSession::Create(Kernel::KernelCore&, std::__1::shared_ptr<Kernel::Session>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::$_0&, unsigned long, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >(Kernel::ServerSession::Create(Kernel::KernelCore&, std::__1::shared_ptr<Kernel::Session>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::$_0&, unsigned long&&, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >&&) type_traits:3899 (yuzu-cmd:x86_64+0x1003ec763)
    #27 void std::__1::__invoke_void_return_wrapper<void>::__call<Kernel::ServerSession::Create(Kernel::KernelCore&, std::__1::shared_ptr<Kernel::Session>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::$_0&, unsigned long, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >(Kernel::ServerSession::Create(Kernel::KernelCore&, std::__1::shared_ptr<Kernel::Session>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::$_0&, unsigned long&&, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >&&) __functional_base:348 (yuzu-cmd:x86_64+0x1003ec65a)
    #28 std::__1::__function::__alloc_func<Kernel::ServerSession::Create(Kernel::KernelCore&, std::__1::shared_ptr<Kernel::Session>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::$_0, std::__1::allocator<Kernel::ServerSession::Create(Kernel::KernelCore&, std::__1::shared_ptr<Kernel::Session>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::$_0>, void (unsigned long, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >)>::operator()(unsigned long&&, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >&&) functional:1557 (yuzu-cmd:x86_64+0x1003ec5ba)
    #29 std::__1::__function::__func<Kernel::ServerSession::Create(Kernel::KernelCore&, std::__1::shared_ptr<Kernel::Session>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::$_0, std::__1::allocator<Kernel::ServerSession::Create(Kernel::KernelCore&, std::__1::shared_ptr<Kernel::Session>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::$_0>, void (unsigned long, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >)>::operator()(unsigned long&&, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >&&) functional:1731 (yuzu-cmd:x86_64+0x1003e9d19)
    #30 std::__1::__function::__value_func<void (unsigned long, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >)>::operator()(unsigned long&&, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >&&) const functional:1884 (yuzu-cmd:x86_64+0x10011fc00)
    #31 std::__1::function<void (unsigned long, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >)>::operator()(unsigned long, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >) const functional:2556 (yuzu-cmd:x86_64+0x100112f68)
    #32 Core::Timing::CoreTiming::Advance() core_timing.cpp:199 (yuzu-cmd:x86_64+0x100112872)
    #33 Core::Timing::CoreTiming::ThreadLoop() core_timing.cpp:220 (yuzu-cmd:x86_64+0x1001101f8)
    #34 Core::Timing::CoreTiming::ThreadEntry(Core::Timing::CoreTiming&) core_timing.cpp:51 (yuzu-cmd:x86_64+0x100110108)
    #35 decltype(std::__1::forward<void (*)(Core::Timing::CoreTiming&)>(fp)(std::__1::forward<std::__1::reference_wrapper<Core::Timing::CoreTiming> >(fp0))) std::__1::__invoke<void (*)(Core::Timing::CoreTiming&), std::__1::reference_wrapper<Core::Timing::CoreTiming> >(void (*&&)(Core::Timing::CoreTiming&), std::__1::reference_wrapper<Core::Timing::CoreTiming>&&) type_traits:3899 (yuzu-cmd:x86_64+0x10011b7c5)
    #36 void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(Core::Timing::CoreTiming&), std::__1::reference_wrapper<Core::Timing::CoreTiming>, 2ul>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(Core::Timing::CoreTiming&), std::__1::reference_wrapper<Core::Timing::CoreTiming> >&, std::__1::__tuple_indices<2ul>) thread:280 (yuzu-cmd:x86_64+0x10011b6b1)
    #37 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(Core::Timing::CoreTiming&), std::__1::reference_wrapper<Core::Timing::CoreTiming> > >(void*) thread:291 (yuzu-cmd:x86_64+0x10011aed9)

  Location is heap block of size 32792 at 0x7bb400050000 allocated by thread T13:
    #0 operator new(unsigned long) <null>:2 (libclang_rt.tsan_osx_dynamic.dylib:x86_64+0x54b2b)
    #1 std::__1::__unique_if<Vulkan::VKScheduler::CommandChunk>::__unique_single std::__1::make_unique<Vulkan::VKScheduler::CommandChunk>() memory:2927 (yuzu-cmd:x86_64+0x101251530)
    #2 Vulkan::VKScheduler::AcquireNewChunk() vk_scheduler.cpp:250 (yuzu-cmd:x86_64+0x10124ebfa)
    #3 Vulkan::VKScheduler::DispatchWork() vk_scheduler.cpp:96 (yuzu-cmd:x86_64+0x10124fe7b)
    #4 Vulkan::VKScheduler::WaitWorker() vk_scheduler.cpp:80 (yuzu-cmd:x86_64+0x10124fcfb)
    #5 Vulkan::VKScheduler::SubmitExecution(VkSemaphore_T*) vk_scheduler.cpp:165 (yuzu-cmd:x86_64+0x10124f88f)
    #6 Vulkan::VKScheduler::Flush(VkSemaphore_T*) vk_scheduler.cpp:67 (yuzu-cmd:x86_64+0x10124f7df)
    #7 Vulkan::RasterizerVulkan::FlushCommands() vk_rasterizer.cpp:706 (yuzu-cmd:x86_64+0x10116c77c)
    #8 Tegra::GPU::FlushCommands() gpu.cpp:194 (yuzu-cmd:x86_64+0x100ca4c9f)
    #9 Tegra::DmaPusher::DispatchCalls() dma_pusher.cpp:38 (yuzu-cmd:x86_64+0x100c3f13e)
    #10 VideoCommon::GPUSynch::PushGPUEntries(Tegra::CommandList&&) gpu_synch.cpp:26 (yuzu-cmd:x86_64+0x100caec4d)
    #11 Service::Nvidia::Devices::nvhost_gpu::SubmitGPFIFOImpl(Service::Nvidia::Devices::nvhost_gpu::IoctlSubmitGpfifo&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >&, Tegra::CommandList&&) nvhost_gpu.cpp:242 (yuzu-cmd:x86_64+0x1007a7765)
    #12 Service::Nvidia::Devices::nvhost_gpu::SubmitGPFIFOBase(std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >&) nvhost_gpu.cpp:290 (yuzu-cmd:x86_64+0x1007a6d98)
    #13 Service::Nvidia::Devices::nvhost_gpu::Ioctl2(Service::Nvidia::Ioctl, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >&) nvhost_gpu.cpp:83 (yuzu-cmd:x86_64+0x1007a6bd3)
    #14 Service::Nvidia::Module::Ioctl2(int, Service::Nvidia::Ioctl, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> >&) nvdrv.cpp:124 (yuzu-cmd:x86_64+0x1007cdf95)
    #15 Service::Nvidia::NVDRV::Ioctl2(Kernel::HLERequestContext&) <null>:2 (yuzu-cmd:x86_64+0x1007c758c)
    #16 Service::ServiceFramework<Service::Nvidia::NVDRV>::Invoker(Service::ServiceFrameworkBase*, void (Service::ServiceFrameworkBase::*)(Kernel::HLERequestContext&), Kernel::HLERequestContext&) <null>:2 (yuzu-cmd:x86_64+0x1007c9630)
    #17 Service::ServiceFrameworkBase::InvokeRequest(Kernel::HLERequestContext&) service.cpp:162 (yuzu-cmd:x86_64+0x10084125e)
    #18 Service::ServiceFrameworkBase::HandleSyncRequest(Kernel::HLERequestContext&) service.cpp:179 (yuzu-cmd:x86_64+0x100841b4b)
    #19 Kernel::ServerSession::CompleteSyncRequest() server_session.cpp:163 (yuzu-cmd:x86_64+0x1003e5e23)
    #20 Kernel::ServerSession::Create(Kernel::KernelCore&, std::__1::shared_ptr<Kernel::Session>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::$_0::operator()(unsigned long, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >) const server_session.cpp:37 (yuzu-cmd:x86_64+0x1003ec818)
    #21 decltype(std::__1::forward<Kernel::ServerSession::Create(Kernel::KernelCore&, std::__1::shared_ptr<Kernel::Session>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::$_0&>(fp)(std::__1::forward<unsigned long>(fp0), std::__1::forward<std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >(fp0))) std::__1::__invoke<Kernel::ServerSession::Create(Kernel::KernelCore&, std::__1::shared_ptr<Kernel::Session>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::$_0&, unsigned long, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >(Kernel::ServerSession::Create(Kernel::KernelCore&, std::__1::shared_ptr<Kernel::Session>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::$_0&, unsigned long&&, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >&&) type_traits:3899 (yuzu-cmd:x86_64+0x1003ec763)
    #22 void std::__1::__invoke_void_return_wrapper<void>::__call<Kernel::ServerSession::Create(Kernel::KernelCore&, std::__1::shared_ptr<Kernel::Session>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::$_0&, unsigned long, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >(Kernel::ServerSession::Create(Kernel::KernelCore&, std::__1::shared_ptr<Kernel::Session>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::$_0&, unsigned long&&, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >&&) __functional_base:348 (yuzu-cmd:x86_64+0x1003ec65a)
    #23 std::__1::__function::__alloc_func<Kernel::ServerSession::Create(Kernel::KernelCore&, std::__1::shared_ptr<Kernel::Session>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::$_0, std::__1::allocator<Kernel::ServerSession::Create(Kernel::KernelCore&, std::__1::shared_ptr<Kernel::Session>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::$_0>, void (unsigned long, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >)>::operator()(unsigned long&&, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >&&) functional:1557 (yuzu-cmd:x86_64+0x1003ec5ba)
    #24 std::__1::__function::__func<Kernel::ServerSession::Create(Kernel::KernelCore&, std::__1::shared_ptr<Kernel::Session>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::$_0, std::__1::allocator<Kernel::ServerSession::Create(Kernel::KernelCore&, std::__1::shared_ptr<Kernel::Session>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::$_0>, void (unsigned long, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >)>::operator()(unsigned long&&, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >&&) functional:1731 (yuzu-cmd:x86_64+0x1003e9d19)
    #25 std::__1::__function::__value_func<void (unsigned long, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >)>::operator()(unsigned long&&, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >&&) const functional:1884 (yuzu-cmd:x86_64+0x10011fc00)
    #26 std::__1::function<void (unsigned long, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >)>::operator()(unsigned long, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >) const functional:2556 (yuzu-cmd:x86_64+0x100112f68)
    #27 Core::Timing::CoreTiming::Advance() core_timing.cpp:199 (yuzu-cmd:x86_64+0x100112872)
    #28 Core::Timing::CoreTiming::ThreadLoop() core_timing.cpp:220 (yuzu-cmd:x86_64+0x1001101f8)
    #29 Core::Timing::CoreTiming::ThreadEntry(Core::Timing::CoreTiming&) core_timing.cpp:51 (yuzu-cmd:x86_64+0x100110108)
    #30 decltype(std::__1::forward<void (*)(Core::Timing::CoreTiming&)>(fp)(std::__1::forward<std::__1::reference_wrapper<Core::Timing::CoreTiming> >(fp0))) std::__1::__invoke<void (*)(Core::Timing::CoreTiming&), std::__1::reference_wrapper<Core::Timing::CoreTiming> >(void (*&&)(Core::Timing::CoreTiming&), std::__1::reference_wrapper<Core::Timing::CoreTiming>&&) type_traits:3899 (yuzu-cmd:x86_64+0x10011b7c5)
    #31 void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(Core::Timing::CoreTiming&), std::__1::reference_wrapper<Core::Timing::CoreTiming>, 2ul>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(Core::Timing::CoreTiming&), std::__1::reference_wrapper<Core::Timing::CoreTiming> >&, std::__1::__tuple_indices<2ul>) thread:280 (yuzu-cmd:x86_64+0x10011b6b1)
    #32 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(Core::Timing::CoreTiming&), std::__1::reference_wrapper<Core::Timing::CoreTiming> > >(void*) thread:291 (yuzu-cmd:x86_64+0x10011aed9)

  Mutex M148472655736472024 is already destroyed.

  Thread T20 (tid=3819717, running) created by main thread at:
    #0 pthread_create <null>:2 (libclang_rt.tsan_osx_dynamic.dylib:x86_64+0xa1ed)
    #1 std::__1::__libcpp_thread_create(_opaque_pthread_t**, void* (*)(void*), void*) __threading_support:504 (yuzu-cmd:x86_64+0x100a7c8be)
    #2 std::__1::thread::thread<void (&)(Service::NVFlinger::NVFlinger&), std::__1::reference_wrapper<Service::NVFlinger::NVFlinger>, void>(void (&)(Service::NVFlinger::NVFlinger&), std::__1::reference_wrapper<Service::NVFlinger::NVFlinger>&&) thread:307 (yuzu-cmd:x86_64+0x10080299c)
    #3 std::__1::thread::thread<void (&)(Service::NVFlinger::NVFlinger&), std::__1::reference_wrapper<Service::NVFlinger::NVFlinger>, void>(void (&)(Service::NVFlinger::NVFlinger&), std::__1::reference_wrapper<Service::NVFlinger::NVFlinger>&&) thread:299 (yuzu-cmd:x86_64+0x100802808)
    #4 std::__1::__unique_if<std::__1::thread>::__unique_single std::__1::make_unique<std::__1::thread, void (&)(Service::NVFlinger::NVFlinger&), std::__1::reference_wrapper<Service::NVFlinger::NVFlinger> >(void (&)(Service::NVFlinger::NVFlinger&), std::__1::reference_wrapper<Service::NVFlinger::NVFlinger>&&) memory:2927 (yuzu-cmd:x86_64+0x1007f64f2)
    #5 Service::NVFlinger::NVFlinger::NVFlinger(Core::System&) nvflinger.cpp:84 (yuzu-cmd:x86_64+0x1007f5bac)
    #6 Service::NVFlinger::NVFlinger::NVFlinger(Core::System&) nvflinger.cpp:60 (yuzu-cmd:x86_64+0x1007f6678)
    #7 std::__1::__compressed_pair_elem<Service::NVFlinger::NVFlinger, 1, false>::__compressed_pair_elem<Core::System&, 0ul>(std::__1::piecewise_construct_t, std::__1::tuple<Core::System&>, std::__1::__tuple_indices<0ul>) memory:2113 (yuzu-cmd:x86_64+0x10084bfb3)
    #8 std::__1::__compressed_pair<std::__1::allocator<Service::NVFlinger::NVFlinger>, Service::NVFlinger::NVFlinger>::__compressed_pair<std::__1::allocator<Service::NVFlinger::NVFlinger>&, Core::System&>(std::__1::piecewise_construct_t, std::__1::tuple<std::__1::allocator<Service::NVFlinger::NVFlinger>&>, std::__1::tuple<Core::System&>) memory:2197 (yuzu-cmd:x86_64+0x10084be91)
    #9 std::__1::__compressed_pair<std::__1::allocator<Service::NVFlinger::NVFlinger>, Service::NVFlinger::NVFlinger>::__compressed_pair<std::__1::allocator<Service::NVFlinger::NVFlinger>&, Core::System&>(std::__1::piecewise_construct_t, std::__1::tuple<std::__1::allocator<Service::NVFlinger::NVFlinger>&>, std::__1::tuple<Core::System&>) memory:2198 (yuzu-cmd:x86_64+0x10084ba48)
    #10 std::__1::__shared_ptr_emplace<Service::NVFlinger::NVFlinger, std::__1::allocator<Service::NVFlinger::NVFlinger> >::__shared_ptr_emplace<Core::System&>(std::__1::allocator<Service::NVFlinger::NVFlinger>, Core::System&) memory:3470 (yuzu-cmd:x86_64+0x10084b972)
    #11 std::__1::__shared_ptr_emplace<Service::NVFlinger::NVFlinger, std::__1::allocator<Service::NVFlinger::NVFlinger> >::__shared_ptr_emplace<Core::System&>(std::__1::allocator<Service::NVFlinger::NVFlinger>, Core::System&) memory:3471 (yuzu-cmd:x86_64+0x10084b208)
    #12 std::__1::enable_if<!(is_array<Service::NVFlinger::NVFlinger>::value), std::__1::shared_ptr<Service::NVFlinger::NVFlinger> >::type std::__1::make_shared<Service::NVFlinger::NVFlinger, Core::System&>(Core::System&) memory:4291 (yuzu-cmd:x86_64+0x100842821)
    #13 Service::Init(std::__1::shared_ptr<Service::SM::ServiceManager>&, Core::System&) service.cpp:195 (yuzu-cmd:x86_64+0x100841d7f)
    #14 Core::System::Impl::Init(Core::System&, Core::Frontend::EmuWindow&) core.cpp:190 (yuzu-cmd:x86_64+0x1000faeae)
    #15 Core::System::Impl::Load(Core::System&, Core::Frontend::EmuWindow&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) core.cpp:219 (yuzu-cmd:x86_64+0x1000f7659)
    #16 Core::System::Load(Core::Frontend::EmuWindow&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) core.cpp:448 (yuzu-cmd:x86_64+0x1000f748b)
    #17 main yuzu.cpp:204 (yuzu-cmd:x86_64+0x10002d006)

  Thread T13 (tid=3819682, running) created by main thread at:
    #0 pthread_create <null>:2 (libclang_rt.tsan_osx_dynamic.dylib:x86_64+0xa1ed)
    #1 std::__1::__libcpp_thread_create(_opaque_pthread_t**, void* (*)(void*), void*) __threading_support:504 (yuzu-cmd:x86_64+0x100a7c8be)
    #2 std::__1::thread::thread<void (&)(Core::Timing::CoreTiming&), std::__1::reference_wrapper<Core::Timing::CoreTiming>, void>(void (&)(Core::Timing::CoreTiming&), std::__1::reference_wrapper<Core::Timing::CoreTiming>&&) thread:307 (yuzu-cmd:x86_64+0x10011abdc)
    #3 std::__1::thread::thread<void (&)(Core::Timing::CoreTiming&), std::__1::reference_wrapper<Core::Timing::CoreTiming>, void>(void (&)(Core::Timing::CoreTiming&), std::__1::reference_wrapper<Core::Timing::CoreTiming>&&) thread:299 (yuzu-cmd:x86_64+0x10011aa48)
    #4 std::__1::__unique_if<std::__1::thread>::__unique_single std::__1::make_unique<std::__1::thread, void (&)(Core::Timing::CoreTiming&), std::__1::reference_wrapper<Core::Timing::CoreTiming> >(void (&)(Core::Timing::CoreTiming&), std::__1::reference_wrapper<Core::Timing::CoreTiming>&&) memory:2927 (yuzu-cmd:x86_64+0x1001107b2)
    #5 Core::Timing::CoreTiming::Initialize(std::__1::function<void ()>&&) core_timing.cpp:62 (yuzu-cmd:x86_64+0x100110562)
    #6 Core::System::Impl::Init(Core::System&, Core::Frontend::EmuWindow&) core.cpp:160 (yuzu-cmd:x86_64+0x1000fab0c)
    #7 Core::System::Impl::Load(Core::System&, Core::Frontend::EmuWindow&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) core.cpp:219 (yuzu-cmd:x86_64+0x1000f7659)
    #8 Core::System::Load(Core::Frontend::EmuWindow&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) core.cpp:448 (yuzu-cmd:x86_64+0x1000f748b)
    #9 main yuzu.cpp:204 (yuzu-cmd:x86_64+0x10002d006)

SUMMARY: ThreadSanitizer: data race vk_scheduler.h:151 in Vulkan::VKScheduler::CommandChunk::Empty() const
==================

comex avatar Nov 23 '20 05:11 comex

Are you running yuzu in multicore? The racy read comes from the NVFlinger thread.

ReinUsesLisp avatar Nov 23 '20 05:11 ReinUsesLisp

Yes, I have multicore enabled.

comex avatar Nov 23 '20 16:11 comex

You shouldn't be using multicore with async disabled. This is disallowed from the UI, but yuzu-cmd doesn't have such protection.

ReinUsesLisp avatar Nov 23 '20 23:11 ReinUsesLisp

is this still an issue ???

benderscruffy avatar Nov 07 '22 08:11 benderscruffy