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

Fix crash on command buffer drop #3726

Merged
merged 2 commits into from
May 3, 2023

Conversation

Wumpf
Copy link
Member

@Wumpf Wumpf commented Apr 24, 2023

Checklist

  • Run cargo clippy.
  • Run RUSTFLAGS=--cfg=web_sys_unstable_apis cargo clippy --target wasm32-unknown-unknown if applicable.
  • Add change to CHANGELOG.md. See simple instructions inside file.

Connections

Fixes #3724

Description

Oversight in: #3657
Passed the wrong object was passed for data to command_buffer_drop, causing type conversion assertion to fail at runtime 😱

Testing

Add minimal repro

let encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
drop(encoder.finish());

to hello triangle. Before: thread 'main' panicked at 'assertion failed: data.is::<T>()', wgpu/src/context.rs:1045:5

Wrong object was passed for `data` to `command_buffer_drop`
wgpu/src/lib.rs Show resolved Hide resolved
wgpu/src/lib.rs Show resolved Hide resolved
@Wumpf
Copy link
Member Author

Wumpf commented Apr 24, 2023

@emilk I agree with the two comments, but I intentionally sticked with the pattern of the other drop implementations in this file to make it less confusing. If there is no data object but an id we are in an invalid state and should not continue either, so we need to handle this error in some way.
The actual issue here is that there’s two option fields that are in sync which is already pretty bad. But since this kind of check only id + unwrap is done in other places as well I decided to stick with it.

Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@cwfitzgerald cwfitzgerald merged commit 1dd105c into gfx-rs:trunk May 3, 2023
@cwfitzgerald cwfitzgerald added the PR: needs back-porting PR with a fix that needs to land on crates label May 3, 2023
@Wumpf Wumpf deleted the fix-drop-command-buffer branch May 3, 2023 13:43
Wumpf added a commit to rerun-io/wgpu that referenced this pull request May 14, 2023
@Wumpf Wumpf mentioned this pull request May 14, 2023
3 tasks
cwfitzgerald pushed a commit that referenced this pull request May 25, 2023
@cwfitzgerald cwfitzgerald removed the PR: needs back-porting PR with a fix that needs to land on crates label Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

assertion failed: data.is::<T>() on command buffer drop
3 participants