-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
ptr-meta: DynMetadata and Pointee::Metadata are not UnwindSafe #86235
Copy link
Copy link
Open
Labels
A-DSTsArea: Dynamically-sized types (DSTs)Area: Dynamically-sized types (DSTs)A-lang-itemArea: Language itemsArea: Language itemsA-raw-pointersArea: raw pointers, MaybeUninit, NonNullArea: raw pointers, MaybeUninit, NonNullC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
Metadata
Metadata
Assignees
Labels
A-DSTsArea: Dynamically-sized types (DSTs)Area: Dynamically-sized types (DSTs)A-lang-itemArea: Language itemsArea: Language itemsA-raw-pointersArea: raw pointers, MaybeUninit, NonNullArea: raw pointers, MaybeUninit, NonNullC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
Type
Fields
Give feedbackNo fields configured for issues without a type.
DynMetadatais onlyUnwindSafeif itsDyntype argument is as well. This is a bit strange asDynMetadatais, data-wise, just a&'staticto an immutable virtual table. There's not a way to observe broken invariant involving such a reference unless somehow the shared library containing the vtable is unloaded -- which violates'static, would be super-mega-bad, and probably shouldn't be happening during unwind.https://rust-lang.github.io/rfcs/2580-ptr-meta.html (#81513) states that
Pointee::MetadataisCopy + Send + Sync + Ord + Hash + Unpin. Given these constraints, as well as the current types being(),usize, andDynMetadata, it seems reasonable to me thatPointee::Metadataalso therefore beUnwindSafe.I understand that
UnwindSafeis currently instd, but with #84662 it will move intolibcore. Provided that we indeed want it as a bound ofPointee::Metadata, we should definitely land this before exposing the ability for users to create custom metadata types.Changing the bounds on
Pointee::Metadatais explicitly mentioned as a concern in these meeting minutes.(Also, the shared library unloading thing may indicate that we may want to drop the
&'staticin favor of*const.)