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

ptr-meta: DynMetadata and Pointee::Metadata are not UnwindSafe #86235

Open
nwsharp opened this issue Jun 12, 2021 · 1 comment
Open

ptr-meta: DynMetadata and Pointee::Metadata are not UnwindSafe #86235

nwsharp opened this issue Jun 12, 2021 · 1 comment
Labels
A-DSTs Area: Dynamically-sized types (DSTs) A-lang-item Area: Language items A-raw-pointers Area: raw pointers, MaybeUninit, NonNull C-enhancement Category: An issue proposing an enhancement or a PR with one. requires-nightly This issue requires a nightly compiler in some way. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@nwsharp
Copy link

nwsharp commented Jun 12, 2021

DynMetadata is only UnwindSafe if its Dyn type argument is as well. This is a bit strange as DynMetadata is, data-wise, just a &'static to 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::Metadata is Copy + Send + Sync + Ord + Hash + Unpin. Given these constraints, as well as the current types being (), usize, and DynMetadata, it seems reasonable to me that Pointee::Metadata also therefore be UnwindSafe.

I understand that UnwindSafe is currently in std, but with #84662 it will move into libcore. Provided that we indeed want it as a bound of Pointee::Metadata, we should definitely land this before exposing the ability for users to create custom metadata types.

Changing the bounds on Pointee::Metadata is explicitly mentioned as a concern in these meeting minutes.

(Also, the shared library unloading thing may indicate that we may want to drop the &'static in favor of *const.)

@nwsharp
Copy link
Author

nwsharp commented Jun 26, 2021

@rustbot label +A-dst +A-lang-item +A-raw-pointers +C-enhancement +requires-nightly +T-libs-api

@rustbot rustbot added A-DSTs Area: Dynamically-sized types (DSTs) A-lang-item Area: Language items A-raw-pointers Area: raw pointers, MaybeUninit, NonNull C-enhancement Category: An issue proposing an enhancement or a PR with one. requires-nightly This issue requires a nightly compiler in some way. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Jun 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-DSTs Area: Dynamically-sized types (DSTs) A-lang-item Area: Language items A-raw-pointers Area: raw pointers, MaybeUninit, NonNull C-enhancement Category: An issue proposing an enhancement or a PR with one. requires-nightly This issue requires a nightly compiler in some way. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants