Open Xaeroxe opened 4 months ago
I marked this as a driver bug since I believe enumerate_instance_extension_properties
should be threadsafe.
That said, this is a bug that wgpu-hal (!) should likely work around by protecting the call with a global mutex just as you suggest 👍
Description ThreadSanitizer shows a data race between threads when these threads are initializing a
wgpu::Instance
, this only happens with an Nvidia GPU under linux. Drivers are from ubuntu packagenvidia-driver-535-server
on Ubuntu 20.04 with x86_64 architecture. This frequently leads to SIGSEGV amongst other problems. I recommend locking access to the body of this function behind some kind of global Mutex. Maybe this should be done inwgpu_core
? Doing this made the problem go away in my own code base. Creatingwgpu::Device
andwgpu::Adapter
doesn't seem to cause this problem, only creatingwgpu::Instance
does.Repro steps Call
wgpu::Instance::new()
on multiple threads simultaneously on a system matching the above description.Expected vs observed behavior I expect this function to be thread safe. On my system it is not thread safe.
Extra materials Command executed:
Snippet from stderr:
Platform Ubuntu 20.04 Nvidia GPU Driver package nvidia-driver-535-server