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

panic! when Instance is destroyed #4604

Closed
RasmusBruhn opened this issue Oct 28, 2023 · 2 comments · Fixed by #5134
Closed

panic! when Instance is destroyed #4604

RasmusBruhn opened this issue Oct 28, 2023 · 2 comments · Fixed by #5134
Labels
api: dx12 Issues with DX12 or DXGI help required We need community help to make this happen. type: bug Something isn't working

Comments

@RasmusBruhn
Copy link

Description
When an Instance is created with flags set to wgpu::InstanceFlags::DEBUG or wgpu::InstanceFlags::DISCARD_HAL_LABELS and later goes out of scope and rust is running in Debug mode it panics with the message:

thread 'main' panicked at 'attempt to subtract with overflow', C:\Users\rasmu.cargo\registry\src\github.com-1ecc6299db9ec823\wgpu-hal-0.18.0\src\auxil\dxgi\exception.rs:34:5

It does not panic with the flag wgpu::InstanceFlags::VALIDATION

If a Surface is created using the Instance it does not panic until the surface is destroyed.

Repro steps
Ideally, a runnable example we can check out.

Expected vs observed behavior

fn main() {
    let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
        backends: wgpu::Backends::all(),
        flags: wgpu::InstanceFlags::DEBUG,
        dx12_shader_compiler: Default::default(),
        gles_minor_version: wgpu::Gles3MinorVersion::Automatic,
    });
}

Platform
OS: Windows 11
System Type: x64-based PC
Processor: AMD Ryzen 5 4500U with Radeon Graphics, 2375 Mhz, 6 Core(s), 6 Logical Processor(s)
GPU: AMD Radeon(TM) Graphics
wgpu version 0.18.0

@teoxoy
Copy link
Member

teoxoy commented Nov 2, 2023

*count_guard -= 1;

This is the offending code, it looks like we don't get to register the handler if we didn't get InstanceFlags::VALIDATION but we are trying to unregister it regardless on drop.

@teoxoy teoxoy added type: bug Something isn't working help required We need community help to make this happen. api: dx12 Issues with DX12 or DXGI labels Nov 2, 2023
@hakolao
Copy link
Contributor

hakolao commented Jan 24, 2024

Also encountered this (with 0.19)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: dx12 Issues with DX12 or DXGI help required We need community help to make this happen. type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants