-
Notifications
You must be signed in to change notification settings - Fork 938
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
STATUS_ACCESS_VIOLATION on exit #5637
Comments
Could you run this in a debugger and show the the backtrace of the segfault |
Certainly!
The main issue seems to be arising from the following function call:
which seems to be introduced in this commit f45d500 As my understanding of these implementation details is limited, any insights or guidance would be greatly appreciated. Thank you! |
The problem is order of dropping of surface and device, even more minimal example without anyhow: use std::sync::Arc;
use wgpu::Features;
use winit::event_loop::EventLoop;
use winit::window::WindowBuilder;
#[pollster::main]
async fn main() {
let event_loop = EventLoop::new().unwrap();
let window = Arc::new(
WindowBuilder::new()
.with_title("Panic! at the disco")
.build(&event_loop)
.unwrap(),
);
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::all(),
..Default::default()
});
let surface = instance.create_surface(window.clone()).unwrap();
let adapter = instance
.request_adapter(&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPreference::HighPerformance,
force_fallback_adapter: false,
compatible_surface: Some(&surface),
})
.await
.unwrap();
let (device, _queue) = adapter
.request_device(
&wgpu::DeviceDescriptor {
label: None,
required_features: Features::default(),
required_limits: Default::default(),
},
None,
)
.await
.unwrap();
let surface_caps = surface.get_capabilities(&adapter);
let surface_format = surface_caps
.formats
.iter()
.find(|format| format.is_srgb())
.unwrap_or(surface_caps.formats.first().unwrap());
let config = wgpu::SurfaceConfiguration {
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
format: *surface_format,
width: window.inner_size().width,
height: window.inner_size().height,
present_mode: surface_caps.present_modes[0],
alpha_mode: surface_caps.alpha_modes[0],
view_formats: vec![],
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &config);
drop(_queue);
drop(device);
drop(surface); // segfaults if both queue and device are dropped before surface
} |
Arc has device stored inside not surface. fixes gfx-rs#5637
Thanks. Straight forward fix of what seems to be a copy paste oopsie.. I was looking at that code too, but I was too focussed on trying to understand how it works that I overlooked this inconsistency. |
Going to push a patch with this tomorrow. |
No, we're doing a really stupid cast in wgpu that is fixed, but needs to be released |
Thank you, i will ignore the error for now |
Description
Since I have updated from 0.19 to 0.20, I am facing an issue similar to #1377.
When my program exits after the first use of the device, in a call
surface.configure(&device, &config)
, the program exits with STATUS_ACCESS_VIOLATION when exiting through an anyhow error bubbled up to pollster or a regular exit with anOk(())
result.When I use the
panic!()
macro, it seems fine. See the various exit scenarios commented in the snippet below.Repro steps
Extracted minimal reproduction from my Main Project in which I am using pollster, anyhow and winit.
Expected vs observed behavior
Running the above code results in the program exiting with STATUS_ACCESS_VIOLATION, but I expect it to exit with code 1 and a message printed:
Specifying
0.19.4
for version in the dependencies does indeed show this expected behavior, where with0.20.0
the access violation is seen.Expected behavior with
0.20.0
is seen when specifyingwgpu::Backends::GL
as opposed toVULKAN
,DX12
orall()
.Platform
reproduced on:
cargo build --target=x86_64-pc-windows-gnu
and ran on the same windows 11adapter, driver and other info, from log from Main Project, that has
env_logger
output:The text was updated successfully, but these errors were encountered: