diff --git a/CHANGELOG.md b/CHANGELOG.md index b932428d3..27043042a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -160,6 +160,7 @@ By @ErichDonGubler in [#6456](https://github.com/gfx-rs/wgpu/pull/6456), [#6148] - Check that begin and end indices are not equal. - Check that at least one index is specified. - Reject destroyed buffers in query set resolution. By @ErichDonGubler in [#6579](https://github.com/gfx-rs/wgpu/pull/6579). +- Fix panic when dropping `Device` on some environments. By @Dinnerbone in [#6681](https://github.com/gfx-rs/wgpu/pull/6681). #### Naga diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index 7b8f011c6..cf5ed7038 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -154,10 +154,9 @@ impl Drop for Device { // SAFETY: We are in the Drop impl and we don't use self.fence anymore after this point. let fence = unsafe { ManuallyDrop::take(&mut self.fence.write()) }; #[cfg(feature = "indirect-validation")] - self.indirect_validation - .take() - .unwrap() - .dispose(self.raw.as_ref()); + if let Some(indirect_validation) = self.indirect_validation.take() { + indirect_validation.dispose(self.raw.as_ref()); + } unsafe { self.raw.destroy_buffer(zero_buffer); self.raw.destroy_fence(fence);