You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Disable unwinding for catch_unwind error payloads.
This does something similar to what was suggested over
#86027 (comment)
that is, to cheat a little bit and tweak/amend the `Box<dyn Any…>` obtained
from `catch_unwind`:
- keep the `.type_id()` the same to avoid breakage with downcasting;
- but make it so the virtual `.drop_in_place()` is somehow overridden with
a shim around the real drop glue that prevents unwinding (_e.g._, by
aborting when that happens).
This is achieved through the `DropNoUnwindSameAnyTypeId<T>`, wrapper:
- with the very same layout as the `T` it wraps;
- with an overridden/fake `.type_id()` so as to impersonate its inner `T`;
- with a manual `impl Drop` which uses an abort bomb to ensure no
unwinding can happen.
That way, the `Box<DropNoUnwindSameAnyTypeId<T>>`, when box-erased to a
`Box<dyn Any…>`, becomes, both layout-wise, and `type_id`-wise,
undistinguishable from a `Box<T>`, thence avoiding any breakage.
And yet, when that `Box<dyn Any…>` is implicitly dropped with
`catch_unwind`s, no further unwinding can happen.
Handle `resume_unwind` payloads too
Clean up logic: centralize drop-override in catch_unwind & virtual method
0 commit comments