Wgpu-rs: Prevent any drop() logic if inside a panic

Created on 30 Jul 2019  路  3Comments  路  Source: gfx-rs/wgpu-rs

It's annoying to see a panic inside a panic if we are seeing drop() failing because we are in process of stack unwinding. We should check for this in drop() implementations and avoid doing anything that can fail.

enhancement good first issue help wanted

All 3 comments

I'd like to take this. Will post progress reports and eventual questions in this thread.

So browsing through the Drop impls, 3 seem they could use this:

  • impl<'a> Drop for SwapChainOutput<'a>
  • impl<'a> Drop for ComputePass<'a>
  • impl<'a> Drop for RenderPass<'a>

They have in common that they act more like RAII guards with more logic than just destructors happening on drop. I personally only ever encountered the SwapChainOutput double panic in the wild.

@kvark do you think we should be preventing the drop logic for all three, or just SwapChainOutput? I also might have missed a place where this would be useful...

EDIT: Just tried inserting a couple a panic!() calls and it seems that preventing the drop logic in SwapChainOutput is enough to prevent the abort.

In all three, if the drop is happening inside a panic, just don't do anything.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JoshuaBatty picture JoshuaBatty  路  5Comments

lordnoriyuki picture lordnoriyuki  路  4Comments

yutannihilation picture yutannihilation  路  4Comments

rukai picture rukai  路  5Comments

gzp-crey picture gzp-crey  路  3Comments