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

Deadlock in Device #5279

Open
eseaflower opened this issue Feb 21, 2024 · 7 comments
Open

Deadlock in Device #5279

eseaflower opened this issue Feb 21, 2024 · 7 comments
Labels
type: bug Something isn't working

Comments

@eseaflower
Copy link

I am using wgpu in a multi-threaded scenario where I have multiple render threads that each manage a separate window/view. I recently upgraded to 0.19 for the improved multi-threading support and started to run into these deadlock scenarios (to be fair I haven't tried to repro with 0.18 so it might be an issue with 0.18 as well).

Here are stack traces from a repro.

    Thread 1
 	wgpu_ffi.dll!parking_lot_core::thread_parker::imp::waitaddress::WaitAddress::wait_on_address(core::sync::atomic::AtomicUsize * self, unsigned int key) Line 107	Rust
 	wgpu_ffi.dll!parking_lot_core::thread_parker::imp::waitaddress::WaitAddress::park(core::sync::atomic::AtomicUsize * self) Line 53	Rust
 	wgpu_ffi.dll!parking_lot_core::thread_parker::imp::impl$1::park(parking_lot_core::thread_parker::imp::ThreadParker * self) Line 121	Rust
 	wgpu_ffi.dll!parking_lot_core::parking_lot::park::closure$0<parking_lot::raw_rwlock::impl$10::lock_common::closure_env$0<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>,parking_lot::raw_rwlock::impl$10::lock_common::closure_env$1<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>,parking_lot::raw_rwlock::impl$10::lock_common::closure_env$2<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>>(parking_lot_core::parking_lot::park::closure_env$0<parking_lot::raw_rwlock::impl$10::lock_common::closure_env$0<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>,parking_lot::raw_rwlock::impl$10::lock_common::closure_env$1<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>,parking_lot::raw_rwlock::impl$10::lock_common::closure_env$2<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>> thread_data, parking_lot_core::parking_lot::ThreadData *) Line 635	Rust
 	[Inline Frame] wgpu_ffi.dll!parking_lot_core::parking_lot::with_thread_data(parking_lot_core::parking_lot::park::closure_env$0<parking_lot::raw_rwlock::impl$10::lock_common::closure_env$0<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>,parking_lot::raw_rwlock::impl$10::lock_common::closure_env$1<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>,parking_lot::raw_rwlock::impl$10::lock_common::closure_env$2<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>> f) Line 207	Rust
 	wgpu_ffi.dll!parking_lot_core::parking_lot::park<parking_lot::raw_rwlock::impl$10::lock_common::closure_env$0<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>,parking_lot::raw_rwlock::impl$10::lock_common::closure_env$1<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>,parking_lot::raw_rwlock::impl$10::lock_common::closure_env$2<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>>(unsigned __int64 key, parking_lot::raw_rwlock::impl$10::lock_common::closure_env$0<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0> timed_out, parking_lot::raw_rwlock::impl$10::lock_common::closure_env$1<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0> park_token, parking_lot::raw_rwlock::impl$10::lock_common::closure_env$2<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>) Line 600	Rust
 	wgpu_ffi.dll!parking_lot::raw_rwlock::RawRwLock::lock_common<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>(enum2$<core::option::Option<std::time::Instant>> self, parking_lot_core::parking_lot::ParkToken token, parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0 validate_flags, unsigned __int64) Line 1115	Rust
 	wgpu_ffi.dll!parking_lot::raw_rwlock::RawRwLock::lock_shared_slow(bool self, enum2$<core::option::Option<std::time::Instant>> recursive) Line 720	Rust
 	wgpu_ffi.dll!parking_lot::raw_rwlock::impl$0::lock_shared(parking_lot::raw_rwlock::RawRwLock * self) Line 109	Rust
 	wgpu_ffi.dll!lock_api::rwlock::RwLock<parking_lot::raw_rwlock::RawRwLock,tuple$<>>::read<parking_lot::raw_rwlock::RawRwLock,tuple$<>>() Line 459	Rust
 	wgpu_ffi.dll!wgpu_core::snatch::SnatchLock::read() Line 80	Rust
>	wgpu_ffi.dll!wgpu_core::global::Global<wgpu_core::identity::IdentityManagerFactory>::queue_write_texture<wgpu_core::identity::IdentityManagerFactory,wgpu_hal::vulkan::Api>(wgpu_core::id::Id<wgpu_core::device::resource::Device<wgpu_hal::empty::Api>> self, wgpu_types::ImageCopyTexture<wgpu_core::id::Id<wgpu_core::resource::Texture<wgpu_hal::empty::Api>>> * queue_id, ref$<slice2$<u8>> destination, wgpu_types::ImageDataLayout * data_layout, wgpu_types::Extent3d * size) Line 788	Rust
 	wgpu_ffi.dll!wgpu::backend::wgpu_core::impl$7::queue_write_texture(wgpu::backend::wgpu_core::ContextWgpuCore * self, wgpu_core::id::Id<wgpu_core::device::resource::Device<wgpu_hal::empty::Api>> * queue, wgpu::backend::wgpu_core::Queue * queue_data, wgpu_types::ImageCopyTexture<ref$<wgpu::Texture>> texture, ref$<slice2$<u8>> data_layout, wgpu_types::ImageDataLayout size, wgpu_types::Extent3d) Line 2177	Rust
 	wgpu_ffi.dll!wgpu::context::impl$5::queue_write_texture<wgpu::backend::wgpu_core::ContextWgpuCore>(wgpu::backend::wgpu_core::ContextWgpuCore * self, wgpu::context::ObjectId * queue, ref$<dyn$<core::any::Any,core::marker::Send,core::marker::Sync>> texture, wgpu_types::ImageCopyTexture<ref$<wgpu::Texture>> data_layout, ref$<slice2$<u8>> size, wgpu_types::ImageDataLayout) Line 2984	Rust
 	wgpu_ffi.dll!wgpu::Queue::write_texture(wgpu_types::ImageCopyTexture<ref$<wgpu::Texture>> self, ref$<slice2$<u8>> texture, wgpu_types::ImageDataLayout data_layout, wgpu_types::Extent3d size) Line 4667	Rust

    
    Thread 2
 	wgpu_ffi.dll!parking_lot_core::thread_parker::imp::waitaddress::WaitAddress::wait_on_address(core::sync::atomic::AtomicUsize * self, unsigned int key) Line 107	Rust
 	wgpu_ffi.dll!parking_lot_core::thread_parker::imp::waitaddress::WaitAddress::park(core::sync::atomic::AtomicUsize * self) Line 53	Rust
 	wgpu_ffi.dll!parking_lot_core::thread_parker::imp::impl$1::park(parking_lot_core::thread_parker::imp::ThreadParker * self) Line 121	Rust
 	wgpu_ffi.dll!parking_lot_core::parking_lot::park::closure$0<parking_lot::raw_mutex::impl$3::lock_slow::closure_env$0,parking_lot::raw_mutex::impl$3::lock_slow::closure_env$1,parking_lot::raw_mutex::impl$3::lock_slow::closure_env$2>(parking_lot_core::parking_lot::park::closure_env$0<parking_lot::raw_mutex::impl$3::lock_slow::closure_env$0,parking_lot::raw_mutex::impl$3::lock_slow::closure_env$1,parking_lot::raw_mutex::impl$3::lock_slow::closure_env$2> thread_data, parking_lot_core::parking_lot::ThreadData *) Line 635	Rust
 	[Inline Frame] wgpu_ffi.dll!parking_lot_core::parking_lot::with_thread_data(parking_lot_core::parking_lot::park::closure_env$0<parking_lot::raw_mutex::impl$3::lock_slow::closure_env$0,parking_lot::raw_mutex::impl$3::lock_slow::closure_env$1,parking_lot::raw_mutex::impl$3::lock_slow::closure_env$2> f) Line 207	Rust
 	wgpu_ffi.dll!parking_lot_core::parking_lot::park<parking_lot::raw_mutex::impl$3::lock_slow::closure_env$0,parking_lot::raw_mutex::impl$3::lock_slow::closure_env$1,parking_lot::raw_mutex::impl$3::lock_slow::closure_env$2>(unsigned __int64 key, parking_lot::raw_mutex::impl$3::lock_slow::closure_env$0 validate, parking_lot::raw_mutex::impl$3::lock_slow::closure_env$1 timed_out, parking_lot::raw_mutex::impl$3::lock_slow::closure_env$2 park_token, parking_lot_core::parking_lot::ParkToken) Line 600	Rust
 	wgpu_ffi.dll!parking_lot::raw_mutex::RawMutex::lock_slow(enum2$<core::option::Option<std::time::Instant>> self) Line 262	Rust
 	wgpu_ffi.dll!parking_lot::raw_mutex::impl$0::lock(parking_lot::raw_mutex::RawMutex * self) Line 72	Rust
 	wgpu_ffi.dll!lock_api::mutex::Mutex<parking_lot::raw_mutex::RawMutex,enum2$<core::option::Option<wgpu_core::device::queue::PendingWrites<wgpu_hal::vulkan::Api>>>>::lock<parking_lot::raw_mutex::RawMutex,enum2$<core::option::Option<wgpu_core::device::queue::PendingWrites<wgpu_hal::vulkan::Api>>>>() Line 219	Rust
>	wgpu_ffi.dll!wgpu_core::global::Global<wgpu_core::identity::IdentityManagerFactory>::queue_write_texture<wgpu_core::identity::IdentityManagerFactory,wgpu_hal::vulkan::Api>(wgpu_core::id::Id<wgpu_core::device::resource::Device<wgpu_hal::empty::Api>> self, wgpu_types::ImageCopyTexture<wgpu_core::id::Id<wgpu_core::resource::Texture<wgpu_hal::empty::Api>>> * queue_id, ref$<slice2$<u8>> destination, wgpu_types::ImageDataLayout * data_layout, wgpu_types::Extent3d * size) Line 743	Rust
 	wgpu_ffi.dll!wgpu::backend::wgpu_core::impl$7::queue_write_texture(wgpu::backend::wgpu_core::ContextWgpuCore * self, wgpu_core::id::Id<wgpu_core::device::resource::Device<wgpu_hal::empty::Api>> * queue, wgpu::backend::wgpu_core::Queue * queue_data, wgpu_types::ImageCopyTexture<ref$<wgpu::Texture>> texture, ref$<slice2$<u8>> data_layout, wgpu_types::ImageDataLayout size, wgpu_types::Extent3d) Line 2177	Rust
 	wgpu_ffi.dll!wgpu::context::impl$5::queue_write_texture<wgpu::backend::wgpu_core::ContextWgpuCore>(wgpu::backend::wgpu_core::ContextWgpuCore * self, wgpu::context::ObjectId * queue, ref$<dyn$<core::any::Any,core::marker::Send,core::marker::Sync>> texture, wgpu_types::ImageCopyTexture<ref$<wgpu::Texture>> data_layout, ref$<slice2$<u8>> size, wgpu_types::ImageDataLayout) Line 2984	Rust
 	wgpu_ffi.dll!wgpu::Queue::write_texture(wgpu_types::ImageCopyTexture<ref$<wgpu::Texture>> self, ref$<slice2$<u8>> texture, wgpu_types::ImageDataLayout data_layout, wgpu_types::Extent3d size) Line 4667	Rust


Thread 3
 	wgpu_ffi.dll!parking_lot_core::thread_parker::imp::waitaddress::WaitAddress::wait_on_address(core::sync::atomic::AtomicUsize * self, unsigned int key) Line 107	Rust
 	wgpu_ffi.dll!parking_lot_core::thread_parker::imp::waitaddress::WaitAddress::park(core::sync::atomic::AtomicUsize * self) Line 53	Rust
 	wgpu_ffi.dll!parking_lot_core::thread_parker::imp::impl$1::park(parking_lot_core::thread_parker::imp::ThreadParker * self) Line 121	Rust
 	wgpu_ffi.dll!parking_lot_core::parking_lot::park::closure$0<parking_lot::raw_mutex::impl$3::lock_slow::closure_env$0,parking_lot::raw_mutex::impl$3::lock_slow::closure_env$1,parking_lot::raw_mutex::impl$3::lock_slow::closure_env$2>(parking_lot_core::parking_lot::park::closure_env$0<parking_lot::raw_mutex::impl$3::lock_slow::closure_env$0,parking_lot::raw_mutex::impl$3::lock_slow::closure_env$1,parking_lot::raw_mutex::impl$3::lock_slow::closure_env$2> thread_data, parking_lot_core::parking_lot::ThreadData *) Line 635	Rust
 	[Inline Frame] wgpu_ffi.dll!parking_lot_core::parking_lot::with_thread_data(parking_lot_core::parking_lot::park::closure_env$0<parking_lot::raw_mutex::impl$3::lock_slow::closure_env$0,parking_lot::raw_mutex::impl$3::lock_slow::closure_env$1,parking_lot::raw_mutex::impl$3::lock_slow::closure_env$2> f) Line 207	Rust
 	wgpu_ffi.dll!parking_lot_core::parking_lot::park<parking_lot::raw_mutex::impl$3::lock_slow::closure_env$0,parking_lot::raw_mutex::impl$3::lock_slow::closure_env$1,parking_lot::raw_mutex::impl$3::lock_slow::closure_env$2>(unsigned __int64 key, parking_lot::raw_mutex::impl$3::lock_slow::closure_env$0 validate, parking_lot::raw_mutex::impl$3::lock_slow::closure_env$1 timed_out, parking_lot::raw_mutex::impl$3::lock_slow::closure_env$2 park_token, parking_lot_core::parking_lot::ParkToken) Line 600	Rust
 	wgpu_ffi.dll!parking_lot::raw_mutex::RawMutex::lock_slow(enum2$<core::option::Option<std::time::Instant>> self) Line 262	Rust
 	wgpu_ffi.dll!parking_lot::raw_mutex::impl$0::lock(parking_lot::raw_mutex::RawMutex * self) Line 72	Rust
 	wgpu_ffi.dll!lock_api::mutex::Mutex<parking_lot::raw_mutex::RawMutex,enum2$<core::option::Option<wgpu_core::device::queue::PendingWrites<wgpu_hal::vulkan::Api>>>>::lock<parking_lot::raw_mutex::RawMutex,enum2$<core::option::Option<wgpu_core::device::queue::PendingWrites<wgpu_hal::vulkan::Api>>>>() Line 219	Rust
>	wgpu_ffi.dll!wgpu_core::global::Global<wgpu_core::identity::IdentityManagerFactory>::queue_submit<wgpu_core::identity::IdentityManagerFactory,wgpu_hal::vulkan::Api>(wgpu_core::id::Id<wgpu_core::device::resource::Device<wgpu_hal::empty::Api>> self, ref$<slice2$<wgpu_core::id::Id<wgpu_core::command::CommandBuffer<wgpu_hal::empty::Api>>>> queue_id) Line 1401	Rust
 	wgpu_ffi.dll!wgpu::backend::wgpu_core::impl$7::queue_submit<core::iter::adapters::map::Map<ref_mut$<dyn$<core::iter::traits::iterator::Iterator<assoc$<Item,tuple$<wgpu::context::ObjectId,alloc::boxed::Box<dyn$<core::any::Any,core::marker::Send,core::marker::Sync>,alloc::alloc::Global>>>>>>,wgpu::context::impl$5::queue_submit::closure_env$0<wgpu::backend::wgpu_core::ContextWgpuCore>>>(wgpu::backend::wgpu_core::ContextWgpuCore * self, wgpu_core::id::Id<wgpu_core::device::resource::Device<wgpu_hal::empty::Api>> * queue, wgpu::backend::wgpu_core::Queue * _queue_data, core::iter::adapters::map::Map<ref_mut$<dyn$<core::iter::traits::iterator::Iterator<assoc$<Item,tuple$<wgpu::context::ObjectId,alloc::boxed::Box<dyn$<core::any::Any,core::marker::Send,core::marker::Sync>,alloc::alloc::Global>>>>>>,wgpu::context::impl$5::queue_submit::closure_env$0<wgpu::backend::wgpu_core::ContextWgpuCore>>) Line 2225	Rust
 	wgpu_ffi.dll!wgpu::context::impl$5::queue_submit<wgpu::backend::wgpu_core::ContextWgpuCore>(wgpu::backend::wgpu_core::ContextWgpuCore * self, wgpu::context::ObjectId * queue, ref$<dyn$<core::any::Any,core::marker::Send,core::marker::Sync>>) Line 3014	Rust
 	wgpu_ffi.dll!wgpu::Queue::submit<core::iter::sources::once::Once<wgpu::CommandBuffer>>(core::iter::sources::once::Once<wgpu::CommandBuffer> self) Line 4696	Rust


    Thread 4
 	wgpu_ffi.dll!parking_lot_core::thread_parker::imp::waitaddress::WaitAddress::wait_on_address(core::sync::atomic::AtomicUsize * self, unsigned int key) Line 107	Rust
 	wgpu_ffi.dll!parking_lot_core::thread_parker::imp::waitaddress::WaitAddress::park(core::sync::atomic::AtomicUsize * self) Line 53	Rust
 	wgpu_ffi.dll!parking_lot_core::thread_parker::imp::impl$1::park(parking_lot_core::thread_parker::imp::ThreadParker * self) Line 121	Rust
 	wgpu_ffi.dll!parking_lot_core::parking_lot::park::closure$0<parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$0,parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$1,parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$2>(parking_lot_core::parking_lot::park::closure_env$0<parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$0,parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$1,parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$2> thread_data, parking_lot_core::parking_lot::ThreadData *) Line 635	Rust
 	[Inline Frame] wgpu_ffi.dll!parking_lot_core::parking_lot::with_thread_data(parking_lot_core::parking_lot::park::closure_env$0<parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$0,parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$1,parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$2> f) Line 207	Rust
 	wgpu_ffi.dll!parking_lot_core::parking_lot::park<parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$0,parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$1,parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$2>(unsigned __int64 key, parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$0 validate, parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$1 park_token, parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$2) Line 600	Rust
 	wgpu_ffi.dll!parking_lot::raw_rwlock::RawRwLock::wait_for_readers(enum2$<core::option::Option<std::time::Instant>> self, unsigned __int64 prev_value) Line 1013	Rust
 	wgpu_ffi.dll!parking_lot::raw_rwlock::RawRwLock::lock_exclusive_slow(enum2$<core::option::Option<std::time::Instant>> self) Line 644	Rust
 	wgpu_ffi.dll!parking_lot::raw_rwlock::impl$0::lock_exclusive(parking_lot::raw_rwlock::RawRwLock * self) Line 73	Rust
 	wgpu_ffi.dll!lock_api::rwlock::RwLock<parking_lot::raw_rwlock::RawRwLock,tuple$<>>::write<parking_lot::raw_rwlock::RawRwLock,tuple$<>>() Line 491	Rust
 	wgpu_ffi.dll!wgpu_core::snatch::SnatchLock::write() Line 89	Rust
>	wgpu_ffi.dll!wgpu_core::global::Global<wgpu_core::identity::IdentityManagerFactory>::surface_present<wgpu_core::identity::IdentityManagerFactory,wgpu_hal::vulkan::Api>(wgpu_core::id::Id<wgpu_core::instance::Surface> self) Line 326	Rust
 	wgpu_ffi.dll!wgpu::backend::wgpu_core::impl$7::surface_present(wgpu::backend::wgpu_core::ContextWgpuCore * self, wgpu_core::id::Id<wgpu_core::resource::Texture<wgpu_hal::empty::Api>> * texture, wgpu::backend::wgpu_core::SurfaceOutputDetail * detail) Line 772	Rust
 	wgpu_ffi.dll!wgpu::context::impl$5::surface_present<wgpu::backend::wgpu_core::ContextWgpuCore>(wgpu::backend::wgpu_core::ContextWgpuCore * self, wgpu::context::ObjectId * texture, ref$<dyn$<wgpu::send_sync::AnyWasmNotSendSync>>) Line 2152	Rust
 	wgpu_ffi.dll!wgpu::SurfaceTexture::present(wgpu::SurfaceTexture self) Line 4749	Rust


Thread 1 and Thread 2 are both executing queue_write_texture. queue_write_texture first locks device.pending_writes.lock() (line 743 in queue.rs) then later acquires a read lock on the device.snatchable_lock.read() (line 788 in queue.rs).

Thread 3 is executing a queue_submit. queue_submit first acquires a read lock on device.snatchable_lock.read() (line 1120 in queue.rs) then later acquires the device.pending_writes.lock() (line 1401 in queue.rs)

If all these locks were exclusive it would be an obvious deadlock since the order the locks are taken in are different in queue_write_texture and queue_submit, but the device.snatchable_lock is an RwLock and only read access is requested. This last bit tripped me up a bit. I think the deadlock comes when we introduce Thread 4.

Thread 4 is doing a SurfaceTexture::present(). On line 326 in present.rs a write lock is acquired on device.snatchable_lock.write(). This attempt will block since Thread 3 already holds a read lock on device.snatchable_lock.

As per the documentation of parking_lot::RwLock:
"This lock uses a task-fair locking policy which avoids both reader and writer starvation. This means that readers trying to acquire the lock will block even if the lock is unlocked when there are writers waiting to acquire the lock. Because of this, attempts to recursively acquire a read lock within a single thread may result in a deadlock." (emphasis is mine)

This means that we have a deadlock:
Thread 1 is waiting for Thread 4 (the RwLock being fair and will block new readers since there is a writer waiting)
Thread 4 is waiting for Thread 3 (Thread 3 holds a read access to the snatchable_lock)
Thread 3 is waiting for Thread 1 (Thread 1 holds the device.pending_writes)

I don't know the codebase at all, so I can't suggest how to fix this, but hopefully this investigation can help pinpoint the problem.

Platform:
wgpu 0.19.1
OS Win 11

@nical nical added the type: bug Something isn't working label Feb 21, 2024
@lucasmerlin
Copy link

I'm sporadically experiencing a similar deadlock in my app, I think it might be the same issue. In my case one thread is calling device.create_buffer_init and the other is calling queue.write_texture. For me it started happening after the update to wgpu 0.19, at least that's when I've first experienced it.

Full Backtrace

2024-02-24T17:29:23.921027Z ERROR hellopaint: 1 deadlocks detected
2024-02-24T17:29:23.921039Z ERROR hellopaint: Deadlock #0
2024-02-24T17:29:23.921040Z ERROR hellopaint: Thread Id 10013274
2024-02-24T17:29:23.921041Z ERROR hellopaint:    0:        0x101c280a4 - backtrace::backtrace::libunwind::trace::h05b18869e77a3056
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/libunwind.rs:93:5
                           backtrace::backtrace::trace_unsynchronized::h4e268f97912c40f0
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/mod.rs:66:5
                           backtrace::backtrace::trace::h0ae78ae4ea2c9760
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/mod.rs:53:14
                           backtrace::capture::Backtrace::create::h046c9ad521097c5d
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/capture.rs:176:9
   1:        0x101c28008 - backtrace::capture::Backtrace::new::hd1155cd849edc772
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/capture.rs:140:22
   2:        0x101c013c4 - parking_lot_core::parking_lot::deadlock_impl::on_unpark::he5878db5614d1735
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/parking_lot_core-0.9.9/src/parking_lot.rs:1211:32
   3:        0x101cfd2a8 - parking_lot_core::parking_lot::deadlock::on_unpark::hbbede89537576194
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/parking_lot_core-0.9.9/src/parking_lot.rs:1144:9
                           parking_lot_core::parking_lot::park::{{closure}}::hb7af908da5b2227b
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/parking_lot_core-0.9.9/src/parking_lot.rs:637:17
                           parking_lot_core::parking_lot::with_thread_data::h241371ee435e8b77
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/parking_lot_core-0.9.9/src/parking_lot.rs:207:5
                           parking_lot_core::parking_lot::park::ha1c96c277808ba7c
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/parking_lot_core-0.9.9/src/parking_lot.rs:600:5
                           parking_lot::raw_mutex::RawMutex::lock_slow::h689b17d588053981
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/parking_lot-0.12.1/src/raw_mutex.rs:262:17
   4:        0x101703cec - <parking_lot::raw_mutex::RawMutex as lock_api::mutex::RawMutex>::lock::h472ed02c4be4c094
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/parking_lot-0.12.1/src/raw_mutex.rs:72:13
                           lock_api::mutex::Mutex<R,T>::lock::heacaa2ea98b15450
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lock_api-0.4.11/src/mutex.rs:219:9
                           wgpu_core::resource::Buffer<A>::unmap_inner::h4644431780f03a85
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-core-0.19.0/src/resource.rs:474:64
                           wgpu_core::resource::Buffer<A>::unmap::h7c10479a44468445
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-core-0.19.0/src/resource.rs:412:48
   5:        0x101663444 - wgpu_core::device::global::<impl wgpu_core::global::Global<G>>::buffer_unmap::hd56700970bdae7a7
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-core-0.19.0/src/device/global.rs:2532:9
   6:        0x101763704 - <wgpu::backend::wgpu_core::ContextWgpuCore as wgpu::context::Context>::buffer_unmap::h046dfa58d6ad93df
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.1/src/backend/wgpu_core.rs:1506:15
   7:        0x10176ad6c - <T as wgpu::context::DynContext>::buffer_unmap::hef4540f722eaacb3
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.1/src/context.rs:2458:9
   8:        0x101788c80 - <wgpu::Device as wgpu::util::device::DeviceExt>::create_buffer_init::h63a60541df6d1bd7
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.1/src/util/device.rs:96:13
   9:        0x100fcc980 - hp_lib::surface::surface_renderer::DrawableRenderer::new::h4e552137421c501a
                               at /Users/lucasprivat/IdeaProjects/hellopaint/hellorust/hp-lib/src/surface/surface_renderer.rs:124:26
  10:        0x100fcdf9c - hp_lib::surface::surface_renderer::SurfaceRenderer::create_image::h04c9d3f74e137bd8
                               at /Users/lucasprivat/IdeaProjects/hellopaint/hellorust/hp-lib/src/surface/surface_renderer.rs:375:38
  11:        0x10102633c - hp_lib::surface::surface_actor::SurfaceActor::initialize::h5c6dd37e95680242
                               at /Users/lucasprivat/IdeaProjects/hellopaint/hellorust/hp-lib/src/surface/surface_actor.rs:361:7
  12:        0x10106a8c8 - hp_lib::surface::surface_actor::SurfaceActor::redraw::{{closure}}::ha27aee47e804300a
                               at /Users/lucasprivat/IdeaProjects/hellopaint/hellorust/hp-lib/src/surface/surface_actor.rs:381:5
  13:        0x10106a08c - hp_lib::surface::surface_actor::SurfaceActor::handle_update::{{closure}}::h9dbccc1bd14473a5
                               at /Users/lucasprivat/IdeaProjects/hellopaint/hellorust/hp-lib/src/surface/surface_actor.rs:319:21
  14:        0x101067020 - hp_lib::surface::surface_actor::SurfaceActor::handle_message::{{closure}}::h617e3ba0187d9ef1
                               at /Users/lucasprivat/IdeaProjects/hellopaint/hellorust/hp-lib/src/surface/surface_actor.rs:148:51
                           hp_lib::surface::surface_actor::SurfaceActor::run::{{closure}}::hef542bbeeb247104
                               at /Users/lucasprivat/IdeaProjects/hellopaint/hellorust/hp-lib/src/surface/surface_actor.rs:122:38
                           hp_lib::surface::surface::create_surface::{{closure}}::h0727240251d5f38b
                               at /Users/lucasprivat/IdeaProjects/hellopaint/hellorust/hp-lib/src/surface/surface.rs:82:25
                           <core::pin::Pin<P> as core::future::future::Future>::poll::h181e5f9e2d68a29a
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/future/future.rs:124:9
  15:        0x10104a014 - tokio::runtime::task::core::Core<T,S>::poll::{{closure}}::h0eb8944e3a0ac53a
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/core.rs:328:17
                           tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut::hca9285a454b17b41
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/loom/std/unsafe_cell.rs:16:9
                           tokio::runtime::task::core::Core<T,S>::poll::h209c45d0733d918e
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/core.rs:317:13
  16:        0x100fbe7f0 - tokio::runtime::task::harness::poll_future::{{closure}}::h46d39912b211e39a
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:485:19
                           <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h9ff6b6fa9fcdc9b7
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panic/unwind_safe.rs:272:9
                           std::panicking::try::do_call::h17331b8838453526
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
                           std::panicking::try::h8e5d13539c307bd0
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
                           std::panic::catch_unwind::h0d4e13f9c25db12f
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
                           tokio::runtime::task::harness::poll_future::h272a3f4cdcb6ea01
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:473:18
                           tokio::runtime::task::harness::Harness<T,S>::poll_inner::h017303923f605baa
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:208:27
                           tokio::runtime::task::harness::Harness<T,S>::poll::hda42bcb4d33d2931
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:153:15
  17:        0x101aae16c - tokio::runtime::task::raw::RawTask::poll::h9ed4baa6980cc940
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/raw.rs:201:18
                           tokio::runtime::task::LocalNotified<S>::run::h81ee62bcf32a64fc
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/mod.rs:416:9
                           tokio::runtime::scheduler::multi_thread::worker::Context::run_task::{{closure}}::he6d081adeed2ffd1
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/multi_thread/worker.rs:576:18
                           tokio::runtime::coop::with_budget::h2330228ff0372581
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/coop.rs:107:5
                           tokio::runtime::coop::budget::hebdac7c46f02674a
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/coop.rs:73:5
                           tokio::runtime::scheduler::multi_thread::worker::Context::run_task::h18e67897c8bf25b0
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/multi_thread/worker.rs:575:9
  18:        0x101aacd1c - tokio::runtime::scheduler::multi_thread::worker::Context::run::h50b3d02742dc19f0
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/multi_thread/worker.rs:526:24
  19:        0x101abd820 - tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}::{{closure}}::h636301a799715ecd
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/multi_thread/worker.rs:491:21
                           tokio::runtime::context::scoped::Scoped<T>::set::h07bc3de607c0791b
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/context/scoped.rs:40:9
                           tokio::runtime::context::set_scheduler::{{closure}}::h7fa33e198b4e31ec
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/context.rs:176:26
                           std::thread::local::LocalKey<T>::try_with::hb532d808376cea4a
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/local.rs:270:16
                           std::thread::local::LocalKey<T>::with::hc8cf64bfa962ef07
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/local.rs:246:9
                           tokio::runtime::context::set_scheduler::hd606b0957d010427
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/context.rs:176:17
  20:        0x101aacaf4 - tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}::hdc068e0162be5f9e
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/multi_thread/worker.rs:486:9
                           tokio::runtime::context::runtime::enter_runtime::he537540948684e5b
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/context/runtime.rs:65:16
                           tokio::runtime::scheduler::multi_thread::worker::run::h941fd9d1f9d0fe86
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/multi_thread/worker.rs:478:5
  21:        0x101ac0fe8 - tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{{closure}}::heb3ad027b1142d60
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/multi_thread/worker.rs:447:45
                           <tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll::h2e8eed9140290aa6
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/blocking/task.rs:42:21
  22:        0x101acf928 - tokio::runtime::task::core::Core<T,S>::poll::{{closure}}::h7e3f3aa0c6d44880
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/core.rs:328:17
                           tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut::h5f3906a0f5a66b11
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/loom/std/unsafe_cell.rs:16:9
                           tokio::runtime::task::core::Core<T,S>::poll::hb6b38c1878c7929f
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/core.rs:317:13
  23:        0x101aa4650 - tokio::runtime::task::harness::poll_future::{{closure}}::h72e57159be3f8688
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:485:19
                           <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h390a3d97910cfb10
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panic/unwind_safe.rs:272:9
                           std::panicking::try::do_call::h94d25836d8f6a622
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
                           std::panicking::try::hc2b95d90bc87a5ce
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
                           std::panic::catch_unwind::h42c51d03e85e460b
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
                           tokio::runtime::task::harness::poll_future::hd4b22af39c6cc3c9
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:473:18
                           tokio::runtime::task::harness::Harness<T,S>::poll_inner::hef207285743cdfc0
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:208:27
                           tokio::runtime::task::harness::Harness<T,S>::poll::h25f069d8df16b7a5
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:153:15
  24:        0x101ab7628 - tokio::runtime::task::raw::RawTask::poll::h9ed4baa6980cc940
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/raw.rs:201:18
                           tokio::runtime::task::UnownedTask<S>::run::h6a269cb43722bb83
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/mod.rs:453:9
                           tokio::runtime::blocking::pool::Task::run::h9ed6d2a4fc77e8d3
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/blocking/pool.rs:159:9
                           tokio::runtime::blocking::pool::Inner::run::h20a77b4d8ceeea2d
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/blocking/pool.rs:513:17
  25:        0x101ad10e4 - tokio::runtime::blocking::pool::Spawner::spawn_thread::{{closure}}::h4cc158654f9cba24
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/blocking/pool.rs:471:13
                           std::sys_common::backtrace::__rust_begin_short_backtrace::hf4cb9e032eb87b25
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:155:18
  26:        0x101ad1ec8 - std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}::hf0a9c3e9e76e98f1
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/mod.rs:529:17
                           <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h401499b3ccaebb5a
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panic/unwind_safe.rs:272:9
                           std::panicking::try::do_call::h6085a92afa65c2b1
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
                           std::panicking::try::h95fc44e2f3720045
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
                           std::panic::catch_unwind::h61f136682013990a
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
                           std::thread::Builder::spawn_unchecked_::{{closure}}::h7fcc748216e5d52a
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/mod.rs:528:30
                           core::ops::function::FnOnce::call_once{{vtable.shim}}::hce443b910b0738fd
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5
  27:        0x101c58d64 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h122931d29f919766
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/alloc/src/boxed.rs:2015:9
                           <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h222f385c86e71c13
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/alloc/src/boxed.rs:2015:9
                           std::sys::unix::thread::Thread::new::thread_start::h8dda2af345bab446
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys/unix/thread.rs:108:17
  28:        0x1819ea034 - __pthread_joiner_wake

2024-02-24T17:29:23.921161Z ERROR hellopaint: Thread Id 10013277
2024-02-24T17:29:23.921165Z ERROR hellopaint:    0:        0x101c280a4 - backtrace::backtrace::libunwind::trace::h05b18869e77a3056
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/libunwind.rs:93:5
                           backtrace::backtrace::trace_unsynchronized::h4e268f97912c40f0
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/mod.rs:66:5
                           backtrace::backtrace::trace::h0ae78ae4ea2c9760
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/mod.rs:53:14
                           backtrace::capture::Backtrace::create::h046c9ad521097c5d
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/capture.rs:176:9
   1:        0x101c28008 - backtrace::capture::Backtrace::new::hd1155cd849edc772
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/capture.rs:140:22
   2:        0x101c013c4 - parking_lot_core::parking_lot::deadlock_impl::on_unpark::he5878db5614d1735
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/parking_lot_core-0.9.9/src/parking_lot.rs:1211:32
   3:        0x101cfc2f0 - parking_lot_core::parking_lot::deadlock::on_unpark::hbbede89537576194
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/parking_lot_core-0.9.9/src/parking_lot.rs:1144:9
                           parking_lot_core::parking_lot::park::{{closure}}::hac82d7fe2f86fe09
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/parking_lot_core-0.9.9/src/parking_lot.rs:637:17
                           parking_lot_core::parking_lot::with_thread_data::he32c700b6e4eceb7
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/parking_lot_core-0.9.9/src/parking_lot.rs:207:5
                           parking_lot_core::parking_lot::park::h2da61c3453c1d9d0
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/parking_lot_core-0.9.9/src/parking_lot.rs:600:5
                           parking_lot::raw_rwlock::RawRwLock::lock_common::h7e3a501f971fa3d3
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/parking_lot-0.12.1/src/raw_rwlock.rs:1115:17
                           parking_lot::raw_rwlock::RawRwLock::lock_shared_slow::h70014a3adb5eb91a
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/parking_lot-0.12.1/src/raw_rwlock.rs:719:9
   4:        0x10180252c - <parking_lot::raw_rwlock::RawRwLock as lock_api::rwlock::RawRwLock>::lock_shared::h5342311342ad5ef0
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/parking_lot-0.12.1/src/raw_rwlock.rs:109:26
                           lock_api::rwlock::RwLock<R,T>::read::ha8cd05768ec111b6
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lock_api-0.4.11/src/rwlock.rs:459:9
                           wgpu_core::snatch::SnatchLock::read::he43d14e2793b181c
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-core-0.19.0/src/snatch.rs:80:31
   5:        0x10165e7a8 - wgpu_core::device::queue::<impl wgpu_core::global::Global<G>>::queue_write_texture::hd99f543d8585a41e
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-core-0.19.0/src/device/queue.rs:788:28
   6:        0x101767a04 - <wgpu::backend::wgpu_core::ContextWgpuCore as wgpu::context::Context>::queue_write_texture::h74304005c6087514
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.1/src/backend/wgpu_core.rs:2177:15
   7:        0x10176d1ac - <T as wgpu::context::DynContext>::queue_write_texture::h3b9c9b20f817f19c
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.1/src/context.rs:2984:9
   8:        0x10178b260 - wgpu::Queue::write_texture::h5d23b1807d6f6a89
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.1/src/lib.rs:4658:9
   9:        0x10134ed0c - hp_wgpu_utils::network_image::native::<impl hp_wgpu_utils::network_image::OwnedImage>::from_rgba_image::h4d71792faa4da17f
                               at /Users/lucasprivat/IdeaProjects/hellopaint/hellorust/hp-wgpu-utils/src/network_image/native.rs:115:5
  10:        0x10105f38c - hp_wgpu_utils::network_image::native::<impl hp_wgpu_utils::network_image::OwnedImage>::load_from_url::{{closure}}::{{closure}}::h2c39b2ee35a4e42f
                               at /Users/lucasprivat/IdeaProjects/hellopaint/hellorust/hp-wgpu-utils/src/network_image/native.rs:43:5
                           hp_wgpu_utils::network_image::native::<impl hp_wgpu_utils::network_image::OwnedImage>::load_from_url::{{closure}}::h2aa8360de7009769
                               at /Users/lucasprivat/IdeaProjects/hellopaint/hellorust/hp-wgpu-utils/src/network_image/native.rs:15:3
  11:        0x101069d40 - hp_lib::surface::surface_actor::SurfaceActor::handle_update::{{closure}}::h9dbccc1bd14473a5
                               at /Users/lucasprivat/IdeaProjects/hellopaint/hellorust/hp-lib/src/surface/surface_actor.rs:302:14
  12:        0x101067020 - hp_lib::surface::surface_actor::SurfaceActor::handle_message::{{closure}}::h617e3ba0187d9ef1
                               at /Users/lucasprivat/IdeaProjects/hellopaint/hellorust/hp-lib/src/surface/surface_actor.rs:148:51
                           hp_lib::surface::surface_actor::SurfaceActor::run::{{closure}}::hef542bbeeb247104
                               at /Users/lucasprivat/IdeaProjects/hellopaint/hellorust/hp-lib/src/surface/surface_actor.rs:122:38
                           hp_lib::surface::surface::create_surface::{{closure}}::h0727240251d5f38b
                               at /Users/lucasprivat/IdeaProjects/hellopaint/hellorust/hp-lib/src/surface/surface.rs:82:25
                           <core::pin::Pin<P> as core::future::future::Future>::poll::h181e5f9e2d68a29a
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/future/future.rs:124:9
  13:        0x10104a014 - tokio::runtime::task::core::Core<T,S>::poll::{{closure}}::h0eb8944e3a0ac53a
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/core.rs:328:17
                           tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut::hca9285a454b17b41
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/loom/std/unsafe_cell.rs:16:9
                           tokio::runtime::task::core::Core<T,S>::poll::h209c45d0733d918e
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/core.rs:317:13
  14:        0x100fbe7f0 - tokio::runtime::task::harness::poll_future::{{closure}}::h46d39912b211e39a
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:485:19
                           <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h9ff6b6fa9fcdc9b7
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panic/unwind_safe.rs:272:9
                           std::panicking::try::do_call::h17331b8838453526
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
                           std::panicking::try::h8e5d13539c307bd0
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
                           std::panic::catch_unwind::h0d4e13f9c25db12f
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
                           tokio::runtime::task::harness::poll_future::h272a3f4cdcb6ea01
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:473:18
                           tokio::runtime::task::harness::Harness<T,S>::poll_inner::h017303923f605baa
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:208:27
                           tokio::runtime::task::harness::Harness<T,S>::poll::hda42bcb4d33d2931
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:153:15
  15:        0x101aae16c - tokio::runtime::task::raw::RawTask::poll::h9ed4baa6980cc940
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/raw.rs:201:18
                           tokio::runtime::task::LocalNotified<S>::run::h81ee62bcf32a64fc
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/mod.rs:416:9
                           tokio::runtime::scheduler::multi_thread::worker::Context::run_task::{{closure}}::he6d081adeed2ffd1
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/multi_thread/worker.rs:576:18
                           tokio::runtime::coop::with_budget::h2330228ff0372581
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/coop.rs:107:5
                           tokio::runtime::coop::budget::hebdac7c46f02674a
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/coop.rs:73:5
                           tokio::runtime::scheduler::multi_thread::worker::Context::run_task::h18e67897c8bf25b0
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/multi_thread/worker.rs:575:9
  16:        0x101aacd1c - tokio::runtime::scheduler::multi_thread::worker::Context::run::h50b3d02742dc19f0
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/multi_thread/worker.rs:526:24
  17:        0x101abd820 - tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}::{{closure}}::h636301a799715ecd
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/multi_thread/worker.rs:491:21
                           tokio::runtime::context::scoped::Scoped<T>::set::h07bc3de607c0791b
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/context/scoped.rs:40:9
                           tokio::runtime::context::set_scheduler::{{closure}}::h7fa33e198b4e31ec
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/context.rs:176:26
                           std::thread::local::LocalKey<T>::try_with::hb532d808376cea4a
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/local.rs:270:16
                           std::thread::local::LocalKey<T>::with::hc8cf64bfa962ef07
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/local.rs:246:9
                           tokio::runtime::context::set_scheduler::hd606b0957d010427
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/context.rs:176:17
  18:        0x101aacaf4 - tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}::hdc068e0162be5f9e
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/multi_thread/worker.rs:486:9
                           tokio::runtime::context::runtime::enter_runtime::he537540948684e5b
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/context/runtime.rs:65:16
                           tokio::runtime::scheduler::multi_thread::worker::run::h941fd9d1f9d0fe86
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/multi_thread/worker.rs:478:5
  19:        0x101ac0fe8 - tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{{closure}}::heb3ad027b1142d60
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/multi_thread/worker.rs:447:45
                           <tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll::h2e8eed9140290aa6
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/blocking/task.rs:42:21
  20:        0x101acf928 - tokio::runtime::task::core::Core<T,S>::poll::{{closure}}::h7e3f3aa0c6d44880
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/core.rs:328:17
                           tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut::h5f3906a0f5a66b11
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/loom/std/unsafe_cell.rs:16:9
                           tokio::runtime::task::core::Core<T,S>::poll::hb6b38c1878c7929f
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/core.rs:317:13
  21:        0x101aa4650 - tokio::runtime::task::harness::poll_future::{{closure}}::h72e57159be3f8688
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:485:19
                           <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h390a3d97910cfb10
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panic/unwind_safe.rs:272:9
                           std::panicking::try::do_call::h94d25836d8f6a622
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
                           std::panicking::try::hc2b95d90bc87a5ce
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
                           std::panic::catch_unwind::h42c51d03e85e460b
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
                           tokio::runtime::task::harness::poll_future::hd4b22af39c6cc3c9
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:473:18
                           tokio::runtime::task::harness::Harness<T,S>::poll_inner::hef207285743cdfc0
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:208:27
                           tokio::runtime::task::harness::Harness<T,S>::poll::h25f069d8df16b7a5
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/harness.rs:153:15
  22:        0x101ab7628 - tokio::runtime::task::raw::RawTask::poll::h9ed4baa6980cc940
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/raw.rs:201:18
                           tokio::runtime::task::UnownedTask<S>::run::h6a269cb43722bb83
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/task/mod.rs:453:9
                           tokio::runtime::blocking::pool::Task::run::h9ed6d2a4fc77e8d3
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/blocking/pool.rs:159:9
                           tokio::runtime::blocking::pool::Inner::run::h20a77b4d8ceeea2d
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/blocking/pool.rs:513:17
  23:        0x101ad10e4 - tokio::runtime::blocking::pool::Spawner::spawn_thread::{{closure}}::h4cc158654f9cba24
                               at /Users/lucasprivat/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/blocking/pool.rs:471:13
                           std::sys_common::backtrace::__rust_begin_short_backtrace::hf4cb9e032eb87b25
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:155:18
  24:        0x101ad1ec8 - std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}::hf0a9c3e9e76e98f1
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/mod.rs:529:17
                           <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h401499b3ccaebb5a
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panic/unwind_safe.rs:272:9
                           std::panicking::try::do_call::h6085a92afa65c2b1
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
                           std::panicking::try::h95fc44e2f3720045
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
                           std::panic::catch_unwind::h61f136682013990a
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
                           std::thread::Builder::spawn_unchecked_::{{closure}}::h7fcc748216e5d52a
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/mod.rs:528:30
                           core::ops::function::FnOnce::call_once{{vtable.shim}}::hce443b910b0738fd
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5
  25:        0x101c58d64 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h122931d29f919766
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/alloc/src/boxed.rs:2015:9
                           <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h222f385c86e71c13
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/alloc/src/boxed.rs:2015:9
                           std::sys::unix::thread::Thread::new::thread_start::h8dda2af345bab446
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys/unix/thread.rs:108:17
  26:        0x1819ea034 - __pthread_joiner_wake


Process finished with exit code 130 (interrupted by signal 2:SIGINT)

@simonask
Copy link

simonask commented Mar 5, 2024

I'm also seeing this very sporadically (twice in the past ~2 weeks), and in my case it seems to only involve surface.present() and queue.submit(). The deadlock looks very similar though: SnatchLock::read() blocking queue.submit(), while SnatchLock::write() is blocking surface.present().

Presentation thread (main):

ntdll.dll!00007ffc711d2f64() (Unknown Source:0)
ntdll.dll!00007ffc711639d5() (Unknown Source:0)
ntdll.dll!00007ffc7117f9cc() (Unknown Source:0)
ntdll.dll!00007ffc7117ba93() (Unknown Source:0)
KernelBase.dll!00007ffc6e5931f3() (Unknown Source:0)
the-community.exe!parking_lot_core::thread_parker::imp::waitaddress::WaitAddress::wait_on_address(core::sync::atomic::AtomicUsize * self, unsigned int key) Line 107 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot_core-0.9.9\src\thread_parker\windows\waitaddress.rs:107)
the-community.exe!parking_lot_core::thread_parker::imp::waitaddress::WaitAddress::park(core::sync::atomic::AtomicUsize * self) Line 53 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot_core-0.9.9\src\thread_parker\windows\waitaddress.rs:53)
the-community.exe!parking_lot_core::thread_parker::imp::impl$1::park(parking_lot_core::thread_parker::imp::ThreadParker * self) Line 121 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot_core-0.9.9\src\thread_parker\windows\mod.rs:121)
the-community.exe!parking_lot_core::parking_lot::park::closure$0<parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$0,parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$1,parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$2>(parking_lot_core::parking_lot::park::closure_env$0<parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$0,parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$1,parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$2> thread_data, parking_lot_core::parking_lot::ThreadData *) Line 635 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot_core-0.9.9\src\parking_lot.rs:635)
[Inline Frame] the-community.exe!parking_lot_core::parking_lot::with_thread_data(parking_lot_core::parking_lot::park::closure_env$0<parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$0,parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$1,parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$2> f) Line 207 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot_core-0.9.9\src\parking_lot.rs:207)
the-community.exe!parking_lot_core::parking_lot::park<parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$0,parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$1,parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$2>(unsigned __int64 key, parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$0 validate, parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$1 park_token, parking_lot::raw_rwlock::impl$10::wait_for_readers::closure_env$2) Line 600 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot_core-0.9.9\src\parking_lot.rs:600)
the-community.exe!parking_lot::raw_rwlock::RawRwLock::wait_for_readers(enum2$<core::option::Option<std::time::Instant>> self, unsigned __int64 prev_value) Line 1013 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot-0.12.1\src\raw_rwlock.rs:1013)
the-community.exe!parking_lot::raw_rwlock::RawRwLock::lock_exclusive_slow(enum2$<core::option::Option<std::time::Instant>> self) Line 644 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot-0.12.1\src\raw_rwlock.rs:644)
the-community.exe!parking_lot::raw_rwlock::impl$0::lock_exclusive(parking_lot::raw_rwlock::RawRwLock * self) Line 73 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot-0.12.1\src\raw_rwlock.rs:73)
the-community.exe!lock_api::rwlock::RwLock<parking_lot::raw_rwlock::RawRwLock,tuple$<>>::write<parking_lot::raw_rwlock::RawRwLock,tuple$<>>() Line 491 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\lock_api-0.4.11\src\rwlock.rs:491)
the-community.exe!wgpu_core::snatch::SnatchLock::write() Line 89 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-core-0.19.0\src\snatch.rs:89)
the-community.exe!wgpu_core::global::Global<wgpu_core::identity::IdentityManagerFactory>::surface_present<wgpu_core::identity::IdentityManagerFactory,wgpu_hal::vulkan::Api>(wgpu_core::id::Id<wgpu_core::instance::Surface> self) Line 326 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-core-0.19.0\src\present.rs:326)
the-community.exe!wgpu::backend::wgpu_core::impl$7::surface_present(wgpu::backend::wgpu_core::ContextWgpuCore * self, wgpu_core::id::Id<wgpu_core::resource::Texture<wgpu_hal::empty::Api>> * texture, wgpu::backend::wgpu_core::SurfaceOutputDetail * detail) Line 772 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-0.19.1\src\backend\wgpu_core.rs:772)
the-community.exe!wgpu::context::impl$5::surface_present<wgpu::backend::wgpu_core::ContextWgpuCore>(wgpu::backend::wgpu_core::ContextWgpuCore * self, wgpu::context::ObjectId * texture, ref$<dyn$<wgpu::send_sync::AnyWasmNotSendSync>>) Line 2152 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-0.19.1\src\context.rs:2152)
the-community.exe!wgpu::SurfaceTexture::present(wgpu::SurfaceTexture self) Line 4749 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-0.19.1\src\lib.rs:4749)
the-community.exe!the_community::Render::render(enum2$<core::option::Option<ref_mut$<the_community::game::render::GameRenderer>>> self, dreamcoat_render::gpu::Gpu * game, the_community::resources::Resources * gpu, the_community::RenderCommands * resources, the_community::RenderFeedback * frame) Line 721 (c:\code\the-community\src\main.rs:721)

Background/simulation thread:

ntdll.dll!00007ffc711d2f64() (Unknown Source:0)
ntdll.dll!00007ffc711639d5() (Unknown Source:0)
ntdll.dll!00007ffc7117f9cc() (Unknown Source:0)
ntdll.dll!00007ffc7117ba93() (Unknown Source:0)
KernelBase.dll!00007ffc6e5931f3() (Unknown Source:0)
the-community.exe!parking_lot_core::thread_parker::imp::waitaddress::WaitAddress::wait_on_address(core::sync::atomic::AtomicUsize * self, unsigned int key) Line 107 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot_core-0.9.9\src\thread_parker\windows\waitaddress.rs:107)
the-community.exe!parking_lot_core::thread_parker::imp::waitaddress::WaitAddress::park(core::sync::atomic::AtomicUsize * self) Line 53 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot_core-0.9.9\src\thread_parker\windows\waitaddress.rs:53)
the-community.exe!parking_lot_core::thread_parker::imp::impl$1::park(parking_lot_core::thread_parker::imp::ThreadParker * self) Line 121 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot_core-0.9.9\src\thread_parker\windows\mod.rs:121)
the-community.exe!parking_lot_core::parking_lot::park::closure$0<parking_lot::raw_rwlock::impl$10::lock_common::closure_env$0<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>,parking_lot::raw_rwlock::impl$10::lock_common::closure_env$1<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>,parking_lot::raw_rwlock::impl$10::lock_common::closure_env$2<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>>(parking_lot_core::parking_lot::park::closure_env$0<parking_lot::raw_rwlock::impl$10::lock_common::closure_env$0<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>,parking_lot::raw_rwlock::impl$10::lock_common::closure_env$1<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>,parking_lot::raw_rwlock::impl$10::lock_common::closure_env$2<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>> thread_data, parking_lot_core::parking_lot::ThreadData *) Line 635 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot_core-0.9.9\src\parking_lot.rs:635)
[Inline Frame] the-community.exe!parking_lot_core::parking_lot::with_thread_data(parking_lot_core::parking_lot::park::closure_env$0<parking_lot::raw_rwlock::impl$10::lock_common::closure_env$0<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>,parking_lot::raw_rwlock::impl$10::lock_common::closure_env$1<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>,parking_lot::raw_rwlock::impl$10::lock_common::closure_env$2<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>> f) Line 207 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot_core-0.9.9\src\parking_lot.rs:207)
the-community.exe!parking_lot_core::parking_lot::park<parking_lot::raw_rwlock::impl$10::lock_common::closure_env$0<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>,parking_lot::raw_rwlock::impl$10::lock_common::closure_env$1<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>,parking_lot::raw_rwlock::impl$10::lock_common::closure_env$2<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>>(unsigned __int64 key, parking_lot::raw_rwlock::impl$10::lock_common::closure_env$0<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0> timed_out, parking_lot::raw_rwlock::impl$10::lock_common::closure_env$1<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0> park_token, parking_lot::raw_rwlock::impl$10::lock_common::closure_env$2<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>) Line 600 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot_core-0.9.9\src\parking_lot.rs:600)
the-community.exe!parking_lot::raw_rwlock::RawRwLock::lock_common<parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0>(enum2$<core::option::Option<std::time::Instant>> self, parking_lot_core::parking_lot::ParkToken token, parking_lot::raw_rwlock::impl$10::lock_shared_slow::closure_env$0 validate_flags, unsigned __int64) Line 1115 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot-0.12.1\src\raw_rwlock.rs:1115)
the-community.exe!parking_lot::raw_rwlock::RawRwLock::lock_shared_slow(bool self, enum2$<core::option::Option<std::time::Instant>> recursive) Line 720 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot-0.12.1\src\raw_rwlock.rs:720)
the-community.exe!parking_lot::raw_rwlock::impl$0::lock_shared(parking_lot::raw_rwlock::RawRwLock * self) Line 109 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\parking_lot-0.12.1\src\raw_rwlock.rs:109)
the-community.exe!lock_api::rwlock::RwLock<parking_lot::raw_rwlock::RawRwLock,tuple$<>>::read<parking_lot::raw_rwlock::RawRwLock,tuple$<>>() Line 459 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\lock_api-0.4.11\src\rwlock.rs:459)
the-community.exe!wgpu_core::snatch::SnatchLock::read() Line 80 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-core-0.19.0\src\snatch.rs:80)
the-community.exe!wgpu_core::command::BakedCommands<wgpu_hal::vulkan::Api>::initialize_buffer_memory<wgpu_hal::vulkan::Api>(wgpu_core::track::Tracker<wgpu_hal::vulkan::Api> * self) Line 228 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-core-0.19.0\src\command\memory_init.rs:228)
the-community.exe!wgpu_core::global::Global<wgpu_core::identity::IdentityManagerFactory>::queue_submit<wgpu_core::identity::IdentityManagerFactory,wgpu_hal::vulkan::Api>(wgpu_core::id::Id<wgpu_core::device::resource::Device<wgpu_hal::empty::Api>> self, ref$<slice2$<wgpu_core::id::Id<wgpu_core::command::CommandBuffer<wgpu_hal::empty::Api>>>> queue_id) Line 1342 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-core-0.19.0\src\device\queue.rs:1342)
the-community.exe!wgpu::backend::wgpu_core::impl$7::queue_submit<core::iter::adapters::map::Map<ref_mut$<dyn$<core::iter::traits::iterator::Iterator<assoc$<Item,tuple$<wgpu::context::ObjectId,alloc::boxed::Box<dyn$<core::any::Any,core::marker::Send,core::marker::Sync>,alloc::alloc::Global>>>>>>,wgpu::context::impl$5::queue_submit::closure_env$0<wgpu::backend::wgpu_core::ContextWgpuCore>>>(wgpu::backend::wgpu_core::ContextWgpuCore * self, wgpu_core::id::Id<wgpu_core::device::resource::Device<wgpu_hal::empty::Api>> * queue, wgpu::backend::wgpu_core::Queue * _queue_data, core::iter::adapters::map::Map<ref_mut$<dyn$<core::iter::traits::iterator::Iterator<assoc$<Item,tuple$<wgpu::context::ObjectId,alloc::boxed::Box<dyn$<core::any::Any,core::marker::Send,core::marker::Sync>,alloc::alloc::Global>>>>>>,wgpu::context::impl$5::queue_submit::closure_env$0<wgpu::backend::wgpu_core::ContextWgpuCore>>) Line 2225 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-0.19.1\src\backend\wgpu_core.rs:2225)
the-community.exe!wgpu::context::impl$5::queue_submit<wgpu::backend::wgpu_core::ContextWgpuCore>(wgpu::backend::wgpu_core::ContextWgpuCore * self, wgpu::context::ObjectId * queue, ref$<dyn$<core::any::Any,core::marker::Send,core::marker::Sync>>) Line 3014 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-0.19.1\src\context.rs:3014)
the-community.exe!wgpu::Queue::submit<enum2$<core::option::Option<wgpu::CommandBuffer>>>(enum2$<core::option::Option<wgpu::CommandBuffer>> self) Line 4696 (c:\Users\simon\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-0.19.1\src\lib.rs:4696)
the-community.exe!the_community::game::simulation::SimulationState::update(the_community::game::simulation::SimulationUpdate self, dreamcoat_render::gpu::Gpu * update, the_community::resources::GameResources * gpu, dreamcoat_render::profiler::GpuProfiler * resources, the_community::game::simulation::SimulationDebugFlags * gpu_profiler) Line 375 (c:\code\the-community\src\game\simulation.rs:375)

@simonask
Copy link

simonask commented Mar 7, 2024

Another data point: This happens significantly more frequently when resizing the window while the background thread is running. This is on Windows, so resize happens in a modal loop, so this issue may interact with rust-windowing/winit#3272.

When the background thread is paused, deadlocks do not seem to occur.

@simonask
Copy link

simonask commented Mar 8, 2024

One more data point: This happens frequently on macOS with MoltenVK (without any resizing etc. going on).

Manually protecting all calls to queue.submit() and surface.present() with an exclusive mutex lock sidesteps the problem (but obviously negates almost all benefits of arcanization).

@SludgePhD
Copy link
Contributor

SludgePhD commented Mar 13, 2024

I'm hitting this bug basically instantly in one of my applications. Some instrumentation of the snatch lock has revealed this (on current trunk, but line numbers may be off by one because I added some single-line comments):

thread '<unnamed>' attempted to acquire a snatch read lock recursively.

- /home/sludge/code/wgpu/wgpu-core/src/device/queue.rs:1160:55
   0: read
             at /home/sludge/code/wgpu/wgpu-core/src/snatch.rs:91:25
   1: queue_submit<wgpu_hal::vulkan::Api>
             at /home/sludge/code/wgpu/wgpu-core/src/device/queue.rs:1160:32
   2: queue_submit<core::iter::adapters::map::Map<&mut dyn core::iter::traits::iterator::Iterator<Item=(wgpu::context::ObjectId, alloc::boxed::Box<(dyn core::any::Any + core::marker::Send + core::marker::Sync), alloc::alloc::Global>)>, wgpu::context::{impl#5}::queue_submit::{closure_env#0}<wgpu::backend::wgpu_core::ContextWgpuCore>>>
             at /home/sludge/code/wgpu/wgpu/src/backend/wgpu_core.rs:2206:27
   3: queue_submit<wgpu::backend::wgpu_core::ContextWgpuCore>
             at /home/sludge/code/wgpu/wgpu/src/context.rs:3014:13
   4: submit<core::iter::adapters::chain::Chain<alloc::vec::into_iter::IntoIter<wgpu::CommandBuffer, alloc::alloc::Global>, core::array::iter::IntoIter<wgpu::CommandBuffer, 1>>>
             at /home/sludge/code/wgpu/wgpu/src/lib.rs:4677:27

- /home/sludge/code/wgpu/wgpu-core/src/command/clear.rs:264:59
   0: read
             at /home/sludge/code/wgpu/wgpu-core/src/snatch.rs:91:25
   1: clear_texture<wgpu_hal::vulkan::Api>
             at /home/sludge/code/wgpu/wgpu-core/src/command/clear.rs:264:24
   2: initialize_texture_memory<wgpu_hal::vulkan::Api>
             at /home/sludge/code/wgpu/wgpu-core/src/command/memory_init.rs:306:36
   3: queue_submit<wgpu_hal::vulkan::Api>
             at /home/sludge/code/wgpu/wgpu-core/src/device/queue.rs:1396:25
   4: queue_submit<core::iter::adapters::map::Map<&mut dyn core::iter::traits::iterator::Iterator<Item=(wgpu::context::ObjectId, alloc::boxed::Box<(dyn core::any::Any + core::marker::Send + core::marker::Sync), alloc::alloc::Global>)>, wgpu::context::{impl#5}::queue_submit::{closure_env#0}<wgpu::backend::wgpu_core::ContextWgpuCore>>>
             at /home/sludge/code/wgpu/wgpu/src/backend/wgpu_core.rs:2206:27
   5: queue_submit<wgpu::backend::wgpu_core::ContextWgpuCore>
             at /home/sludge/code/wgpu/wgpu/src/context.rs:3014:13
   6: submit<core::iter::adapters::chain::Chain<alloc::vec::into_iter::IntoIter<wgpu::CommandBuffer, alloc::alloc::Global>, core::array::iter::IntoIter<wgpu::CommandBuffer, 1>>>
             at /home/sludge/code/wgpu/wgpu/src/lib.rs:4677:27

Generally, a thread must only ever hold a single read lock at a time, otherwise you're immediately open to deadlocks when another thread attempts to acquire a write lock inbetween. The parking_lot::RwLock documentation says:

This lock uses a task-fair locking policy which avoids both reader and writer starvation. This means that readers trying to acquire the lock will block even if the lock is unlocked when there are writers waiting to acquire the lock. Because of this, attempts to recursively acquire a read lock within a single thread may result in a deadlock.

(I'm honestly somewhat surprised that neither the stdlib's nor parking_lot's RwLock provide any instrumentation like this in debug builds, it's very easy to implement)

@jimblandy
Copy link
Member

I haven't worked through this in complete detail, but just on general principles:

wgpu-core should not be trying to take the read guard again. Instead, initialize_texture_memory and clear_texture should require a SnatchGuard as an argument, and queue_submit should pass along the guard that it already has. This is annoying, but for better or worse, that's the way this stuff is supposed to work.

@jimblandy
Copy link
Member

Some instrumentation of the snatch lock has revealed this

@SludgePhD Thank you for this very clear illustration of where the code goes wrong!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants