Inadequate unwind protection for log calls under DX12 #2487
Labels
good first issue
Good for newcomers
help required
We need community help to make this happen.
type: bug
Something isn't working
Description
The
log
macros and functions are internally calls out to "whatever zany stuff the Rust ecosystem has dreamt up" so it's nearly impossible to prove they won't panic. Currentlywgpu
is usinglog
while behind FFI in at least one instance and this is causing dead locks when used withlog4rs
.log4rs
will spawn a thread to roll its file over as part of its rolling_file functionality. After the Rust runtime has calledExitProcess
from Win32 the aforementioned wgpu FFI code is still running. However, Windows does not permit you to spawn a thread afterExitProcess
has been called, so this log statement panics and hangs indefinitely.Repro steps
Add
log4rs
logging using a rolling file appender to awgpu
program using only the DX12 backend, and set the size at which it rolls over to a very small size such that it is rolling over very often. Do not filterwarn
level logs fromwgpu
. Use the log_panics crate to log panics as well. Start and stop the program repeatedly. Eventually it should hang.Attaching a debugger to it will reveal that it has hung due to a panic on a
log
statement behind FFI.Expected vs observed behavior
I expected that
wgpu
would catch_unwind to catch any potentiallog
panic, and then either do nothing, or abort.Platform
Windows 11, wgpu 0.11, rustc 1.58.1
The text was updated successfully, but these errors were encountered: