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

What if DynMetadata wasn't special? #125532

Closed
wants to merge 2 commits into from

Conversation

scottmcm
Copy link
Member

Let's see what CI says (#125508 (comment))...

r? @Nilstrieb

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 25, 2024
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling std v0.0.0 (/checkout/library/std)
error[E0080]: it is undefined behavior to use this value
   --> /checkout/library/alloc/src/boxed/thin.rs:327:56
    |
327 |           let alloc: &<Dyn as Pointee>::Metadata = const {
    |  ________________________________________________________^
328 | |             // FIXME: just call `WithHeader::alloc_layout` with size reset to 0.
329 | |             // Currently that's blocked on `Layout::extend` not being `const fn`.
351 | |             }
352 | |         };
352 | |         };
    | |_________^ constructing invalid value at .<deref>.vtable_ptr: encountered a dangling reference (going beyond the bounds of its allocation)
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
    = note: the raw bytes of the constant (size: 8, align: 8) {
                ╾───alloc58148<imm>───╼                         │ ╾──────╼

note: erroneous constant encountered
   --> /checkout/library/alloc/src/boxed/thin.rs:327:50
    |
    |
327 |           let alloc: &<Dyn as Pointee>::Metadata = const {
    |  __________________________________________________^
328 | |             // FIXME: just call `WithHeader::alloc_layout` with size reset to 0.
329 | |             // Currently that's blocked on `Layout::extend` not being `const fn`.
351 | |             }
352 | |         };
    | |_________^


note: the above error was encountered while instantiating `fn std::boxed::thin::WithHeader::<std::ptr::DynMetadata<dyn std::fmt::Debug>>::new_unsize_zst::<dyn std::fmt::Debug, thin_box::align1zst::Align1Zst>`
    |
    |
218 |         let ptr = WithHeader::<<Dyn as Pointee>::Metadata>::new_unsize_zst::<Dyn, T>(value);

error[E0080]: it is undefined behavior to use this value
   --> /checkout/library/alloc/src/boxed/thin.rs:327:56
    |
    |
327 |           let alloc: &<Dyn as Pointee>::Metadata = const {
    |  ________________________________________________________^
328 | |             // FIXME: just call `WithHeader::alloc_layout` with size reset to 0.
329 | |             // Currently that's blocked on `Layout::extend` not being `const fn`.
351 | |             }
352 | |         };
352 | |         };
    | |_________^ constructing invalid value at .<deref>.vtable_ptr: encountered a dangling reference (going beyond the bounds of its allocation)
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
    = note: the raw bytes of the constant (size: 8, align: 8) {
                ╾───alloc58213<imm>───╼                         │ ╾──────╼


note: the above error was encountered while instantiating `fn std::boxed::thin::WithHeader::<std::ptr::DynMetadata<dyn std::fmt::Debug>>::new_unsize_zst::<dyn std::fmt::Debug, thin_box::align1small::Align1Small>`
    |
    |
218 |         let ptr = WithHeader::<<Dyn as Pointee>::Metadata>::new_unsize_zst::<Dyn, T>(value);

error[E0080]: it is undefined behavior to use this value
   --> /checkout/library/alloc/src/boxed/thin.rs:327:56
    |
    |
327 |           let alloc: &<Dyn as Pointee>::Metadata = const {
    |  ________________________________________________________^
328 | |             // FIXME: just call `WithHeader::alloc_layout` with size reset to 0.
329 | |             // Currently that's blocked on `Layout::extend` not being `const fn`.
351 | |             }
352 | |         };
352 | |         };
    | |_________^ constructing invalid value at .<deref>.vtable_ptr: encountered a dangling reference (going beyond the bounds of its allocation)
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
    = note: the raw bytes of the constant (size: 8, align: 8) {
                ╾───alloc58275<imm>───╼                         │ ╾──────╼


note: the above error was encountered while instantiating `fn std::boxed::thin::WithHeader::<std::ptr::DynMetadata<dyn std::fmt::Debug>>::new_unsize_zst::<dyn std::fmt::Debug, thin_box::align1_size_not_pow2::Align64NotPow2Size>`
    |
    |
218 |         let ptr = WithHeader::<<Dyn as Pointee>::Metadata>::new_unsize_zst::<Dyn, T>(value);

error[E0080]: it is undefined behavior to use this value
   --> /checkout/library/alloc/src/boxed/thin.rs:327:56
    |
    |
327 |           let alloc: &<Dyn as Pointee>::Metadata = const {
    |  ________________________________________________________^
328 | |             // FIXME: just call `WithHeader::alloc_layout` with size reset to 0.
329 | |             // Currently that's blocked on `Layout::extend` not being `const fn`.
351 | |             }
352 | |         };
352 | |         };
    | |_________^ constructing invalid value at .<deref>.vtable_ptr: encountered a dangling reference (going beyond the bounds of its allocation)
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
    = note: the raw bytes of the constant (size: 8, align: 8) {
                ╾───alloc58337<imm>───╼                         │ ╾──────╼


note: the above error was encountered while instantiating `fn std::boxed::thin::WithHeader::<std::ptr::DynMetadata<dyn std::fmt::Debug>>::new_unsize_zst::<dyn std::fmt::Debug, thin_box::align1big::Align1Big>`
    |
    |
218 |         let ptr = WithHeader::<<Dyn as Pointee>::Metadata>::new_unsize_zst::<Dyn, T>(value);

error[E0080]: it is undefined behavior to use this value
   --> /checkout/library/alloc/src/boxed/thin.rs:327:56
    |
    |
327 |           let alloc: &<Dyn as Pointee>::Metadata = const {
    |  ________________________________________________________^
328 | |             // FIXME: just call `WithHeader::alloc_layout` with size reset to 0.
329 | |             // Currently that's blocked on `Layout::extend` not being `const fn`.
351 | |             }
352 | |         };
352 | |         };
    | |_________^ constructing invalid value at .<deref>.vtable_ptr: encountered a dangling reference (going beyond the bounds of its allocation)
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
    = note: the raw bytes of the constant (size: 8, align: 8) {
                ╾───alloc58397<imm>───╼                         │ ╾──────╼


note: the above error was encountered while instantiating `fn std::boxed::thin::WithHeader::<std::ptr::DynMetadata<dyn std::fmt::Debug>>::new_unsize_zst::<dyn std::fmt::Debug, thin_box::align2zst::Align2Zst>`
    |
    |
218 |         let ptr = WithHeader::<<Dyn as Pointee>::Metadata>::new_unsize_zst::<Dyn, T>(value);

error[E0080]: it is undefined behavior to use this value
   --> /checkout/library/alloc/src/boxed/thin.rs:327:56
    |
    |
327 |           let alloc: &<Dyn as Pointee>::Metadata = const {
    |  ________________________________________________________^
328 | |             // FIXME: just call `WithHeader::alloc_layout` with size reset to 0.
329 | |             // Currently that's blocked on `Layout::extend` not being `const fn`.
351 | |             }
352 | |         };
352 | |         };
    | |_________^ constructing invalid value at .<deref>.vtable_ptr: encountered a dangling reference (going beyond the bounds of its allocation)
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
    = note: the raw bytes of the constant (size: 8, align: 8) {
                ╾───alloc58460<imm>───╼                         │ ╾──────╼


note: the above error was encountered while instantiating `fn std::boxed::thin::WithHeader::<std::ptr::DynMetadata<dyn std::fmt::Debug>>::new_unsize_zst::<dyn std::fmt::Debug, thin_box::align2small::Align2Small>`
    |
    |
218 |         let ptr = WithHeader::<<Dyn as Pointee>::Metadata>::new_unsize_zst::<Dyn, T>(value);

error[E0080]: it is undefined behavior to use this value
   --> /checkout/library/alloc/src/boxed/thin.rs:327:56
    |
    |
327 |           let alloc: &<Dyn as Pointee>::Metadata = const {
    |  ________________________________________________________^
328 | |             // FIXME: just call `WithHeader::alloc_layout` with size reset to 0.
329 | |             // Currently that's blocked on `Layout::extend` not being `const fn`.
351 | |             }
352 | |         };
352 | |         };
    | |_________^ constructing invalid value at .<deref>.vtable_ptr: encountered a dangling reference (going beyond the bounds of its allocation)
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
    = note: the raw bytes of the constant (size: 8, align: 8) {
                ╾───alloc58522<imm>───╼                         │ ╾──────╼


note: the above error was encountered while instantiating `fn std::boxed::thin::WithHeader::<std::ptr::DynMetadata<dyn std::fmt::Debug>>::new_unsize_zst::<dyn std::fmt::Debug, thin_box::align2full::Align2Full>`
    |
    |
218 |         let ptr = WithHeader::<<Dyn as Pointee>::Metadata>::new_unsize_zst::<Dyn, T>(value);

error[E0080]: it is undefined behavior to use this value
   --> /checkout/library/alloc/src/boxed/thin.rs:327:56
    |
    |
327 |           let alloc: &<Dyn as Pointee>::Metadata = const {
    |  ________________________________________________________^
328 | |             // FIXME: just call `WithHeader::alloc_layout` with size reset to 0.
329 | |             // Currently that's blocked on `Layout::extend` not being `const fn`.
351 | |             }
352 | |         };
352 | |         };
    | |_________^ constructing invalid value at .<deref>.vtable_ptr: encountered a dangling reference (going beyond the bounds of its allocation)
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
    = note: the raw bytes of the constant (size: 8, align: 8) {
                ╾───alloc58584<imm>───╼                         │ ╾──────╼


note: the above error was encountered while instantiating `fn std::boxed::thin::WithHeader::<std::ptr::DynMetadata<dyn std::fmt::Debug>>::new_unsize_zst::<dyn std::fmt::Debug, thin_box::align2_size_not_pow2::Align2NotPower2Size>`
    |
    |
218 |         let ptr = WithHeader::<<Dyn as Pointee>::Metadata>::new_unsize_zst::<Dyn, T>(value);

error[E0080]: it is undefined behavior to use this value
   --> /checkout/library/alloc/src/boxed/thin.rs:327:56
    |
    |
327 |           let alloc: &<Dyn as Pointee>::Metadata = const {
    |  ________________________________________________________^
328 | |             // FIXME: just call `WithHeader::alloc_layout` with size reset to 0.
329 | |             // Currently that's blocked on `Layout::extend` not being `const fn`.
351 | |             }
352 | |         };
352 | |         };
    | |_________^ constructing invalid value at .<deref>.vtable_ptr: encountered a dangling reference (going beyond the bounds of its allocation)
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
    = note: the raw bytes of the constant (size: 8, align: 8) {
                ╾───alloc58646<imm>───╼                         │ ╾──────╼


note: the above error was encountered while instantiating `fn std::boxed::thin::WithHeader::<std::ptr::DynMetadata<dyn std::fmt::Debug>>::new_unsize_zst::<dyn std::fmt::Debug, thin_box::align2big::Align2Big>`
    |
    |
218 |         let ptr = WithHeader::<<Dyn as Pointee>::Metadata>::new_unsize_zst::<Dyn, T>(value);

error[E0080]: it is undefined behavior to use this value
   --> /checkout/library/alloc/src/boxed/thin.rs:327:56
    |
    |
327 |           let alloc: &<Dyn as Pointee>::Metadata = const {
    |  ________________________________________________________^
328 | |             // FIXME: just call `WithHeader::alloc_layout` with size reset to 0.
329 | |             // Currently that's blocked on `Layout::extend` not being `const fn`.
351 | |             }
352 | |         };
352 | |         };
    | |_________^ constructing invalid value at .<deref>.vtable_ptr: encountered a dangling reference (going beyond the bounds of its allocation)
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
    = note: the raw bytes of the constant (size: 8, align: 8) {
                ╾alloc58706+0x38<imm>─╼                         │ ╾──────╼


note: the above error was encountered while instantiating `fn std::boxed::thin::WithHeader::<std::ptr::DynMetadata<dyn std::fmt::Debug>>::new_unsize_zst::<dyn std::fmt::Debug, thin_box::align64zst::Align64Zst>`
    |
    |
218 |         let ptr = WithHeader::<<Dyn as Pointee>::Metadata>::new_unsize_zst::<Dyn, T>(value);

error[E0080]: it is undefined behavior to use this value
   --> /checkout/library/alloc/src/boxed/thin.rs:327:56
    |
    |
327 |           let alloc: &<Dyn as Pointee>::Metadata = const {
    |  ________________________________________________________^
328 | |             // FIXME: just call `WithHeader::alloc_layout` with size reset to 0.
329 | |             // Currently that's blocked on `Layout::extend` not being `const fn`.
351 | |             }
352 | |         };
352 | |         };
    | |_________^ constructing invalid value at .<deref>.vtable_ptr: encountered a dangling reference (going beyond the bounds of its allocation)
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
    = note: the raw bytes of the constant (size: 8, align: 8) {
                ╾alloc58769+0x38<imm>─╼                         │ ╾──────╼


note: the above error was encountered while instantiating `fn std::boxed::thin::WithHeader::<std::ptr::DynMetadata<dyn std::fmt::Debug>>::new_unsize_zst::<dyn std::fmt::Debug, thin_box::align64small::Align64Small>`
    |
    |
218 |         let ptr = WithHeader::<<Dyn as Pointee>::Metadata>::new_unsize_zst::<Dyn, T>(value);

error[E0080]: it is undefined behavior to use this value
   --> /checkout/library/alloc/src/boxed/thin.rs:327:56
    |
    |
327 |           let alloc: &<Dyn as Pointee>::Metadata = const {
    |  ________________________________________________________^
328 | |             // FIXME: just call `WithHeader::alloc_layout` with size reset to 0.
329 | |             // Currently that's blocked on `Layout::extend` not being `const fn`.
351 | |             }
352 | |         };
352 | |         };
    | |_________^ constructing invalid value at .<deref>.vtable_ptr: encountered a dangling reference (going beyond the bounds of its allocation)
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
    = note: the raw bytes of the constant (size: 8, align: 8) {
                ╾alloc58831+0x38<imm>─╼                         │ ╾──────╼


note: the above error was encountered while instantiating `fn std::boxed::thin::WithHeader::<std::ptr::DynMetadata<dyn std::fmt::Debug>>::new_unsize_zst::<dyn std::fmt::Debug, thin_box::align64med::Align64Med>`
    |
    |
218 |         let ptr = WithHeader::<<Dyn as Pointee>::Metadata>::new_unsize_zst::<Dyn, T>(value);

error[E0080]: it is undefined behavior to use this value
   --> /checkout/library/alloc/src/boxed/thin.rs:327:56
    |
    |
327 |           let alloc: &<Dyn as Pointee>::Metadata = const {
    |  ________________________________________________________^
328 | |             // FIXME: just call `WithHeader::alloc_layout` with size reset to 0.
329 | |             // Currently that's blocked on `Layout::extend` not being `const fn`.
351 | |             }
352 | |         };
352 | |         };
    | |_________^ constructing invalid value at .<deref>.vtable_ptr: encountered a dangling reference (going beyond the bounds of its allocation)
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
    = note: the raw bytes of the constant (size: 8, align: 8) {
                ╾alloc58893+0x38<imm>─╼                         │ ╾──────╼


note: the above error was encountered while instantiating `fn std::boxed::thin::WithHeader::<std::ptr::DynMetadata<dyn std::fmt::Debug>>::new_unsize_zst::<dyn std::fmt::Debug, thin_box::align64_size_not_pow2::Align64NotPow2Size>`
    |
    |
218 |         let ptr = WithHeader::<<Dyn as Pointee>::Metadata>::new_unsize_zst::<Dyn, T>(value);

error[E0080]: it is undefined behavior to use this value
   --> /checkout/library/alloc/src/boxed/thin.rs:327:56
    |
    |
327 |           let alloc: &<Dyn as Pointee>::Metadata = const {
    |  ________________________________________________________^
328 | |             // FIXME: just call `WithHeader::alloc_layout` with size reset to 0.
329 | |             // Currently that's blocked on `Layout::extend` not being `const fn`.
351 | |             }
352 | |         };
352 | |         };
    | |_________^ constructing invalid value at .<deref>.vtable_ptr: encountered a dangling reference (going beyond the bounds of its allocation)
    |
    = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
    = note: the raw bytes of the constant (size: 8, align: 8) {
                ╾alloc58955+0x38<imm>─╼                         │ ╾──────╼


note: the above error was encountered while instantiating `fn std::boxed::thin::WithHeader::<std::ptr::DynMetadata<dyn std::fmt::Debug>>::new_unsize_zst::<dyn std::fmt::Debug, thin_box::align64big::Align64Big>`
    |
    |
218 |         let ptr = WithHeader::<<Dyn as Pointee>::Metadata>::new_unsize_zst::<Dyn, T>(value);

For more information about this error, try `rustc --explain E0080`.
error: could not compile `alloc` (test "alloctests") due to 14 previous errors
warning: build failed, waiting for other jobs to finish...

@scottmcm
Copy link
Member Author

Well, that answers that. If it's an extern type then it's not dereferencable; if it's a real type then Miri expects there to be actual AM memory there.

@RalfJung
Copy link
Member

Yeah, "must point to a vtable" is a primitive concept that must be reflected somehow so we can implement the validity invariant for wide pointers correctly. in LLVM it becomes a form of dereferenceable but that's only correct on the LLVM level, not the MIR level. (Also the size of dereferencability depends on the trait so it still can't be a normal reference there.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants