Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Handle dyn* coercions for values that are represented with
OperandValue::Ref
#104694Handle dyn* coercions for values that are represented with
OperandValue::Ref
#104694Changes from all commits
5f7af80
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is necessary because if we represent the vtable as a reference, then CTFE wants to validate the pointer. However, the vtable is represented by
GlobalAlloc::VTable
, which is treated likeSize::ZERO
. So it complains that we're trying to write 24 bytes into an allocation of size 0.Alternatively, we could fix this instead I guess:
rust/compiler/rustc_const_eval/src/interpret/memory.rs
Line 711 in d962ea5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't happen, validity checking should stop at the
dyn*
and not descend into its components.Did you rebase? #107728 fixed some issues with dyn* handling in the validity check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is based off of a rebased master.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange. Then CTFE should never see this type.
What's the error you are getting otherwise, and for which code? Ideally with RUSTC_CTFE_BACKTRACE=1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
https://github.com/rust-lang/rust/pull/104694/files#diff-60d85c7ca5a99b206384a4ccb596b7e0f9824fd6606ae7241e2d4a4e5ae65025R134
Here we write the vtable to the second part of the scalar pair. So we're trying to write the vtable allocation pointer to a place of type
&'static [usize; 3]
, which then tries to validate that vtable pointer.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's where this comes from. But during CTFE we don't do validation on writes... this should only affect Miri. Still a problem though.
However why wouldn't this also be a problem for vtables in wide pointers?
I'm also worried using a raw pointer type here could have bad side-effects, like losing
nonnull
attributes. IIRC there are two places where we define the layout/type/attributes for fields of wide ptrs anddyn*
and I have no idea what happens when they start to diverge.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably because we don't explicitly split up the write for
&dyn ..
writes into two writes like we do fordyn*
..