-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Fix conversion from Miri Value to ConstValue #50710
Conversation
@@ -0,0 +1,12 @@ | |||
|
|||
#[derive(Eq, PartialEq)] |
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 test works on the nightly playpen: http://play.integer32.com/?gist=550e66e34e4ba58a8e716f800d94520f&version=nightly&mode=debug
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.
The playpen is probably not on the latest nightly.
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.
ah indeed. sorry
.get_alloc(ptr.alloc_id) | ||
.expect("miri allocation never successfully created"); | ||
assert_eq!(align, alloc.align); | ||
let alloc = ecx.memory.get(ptr.alloc_id)?; |
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.
doesn't this change simply turn a panic into an error? How does that fix the regression?
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.
The alloc ID we are trying to read is stored in the EvalContext
and isn't in the global table.
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.
ah. makes sense. Is there any reason reading this should ever fail? If so, then this code is fine. Otherwise it should probably have the panic, right?
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 should really recurse into allocations like mark_static_initialized
and could replace it by calling value_to_const_value
at the end of const_eval.
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.
ah. makes sense. Is there any reason reading this should ever fail?
I don't think this can fail. Value::ByRef
here must always point to a valid AllocId
right?
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.
Might point to an integer address in general, but not as the result of const_eval
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.
value_to_const_value
is really just converting between different representation of Rust values, so it shouldn't fail. I've changed it to use unwrap
so it will panic if it happens to fail.
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
3d50de3
to
81915af
Compare
ty: Ty<'tcx>, | ||
) -> &'tcx ty::Const<'tcx> { | ||
let layout = tcx.layout_of(ty::ParamEnv::reveal_all().and(ty)).unwrap(); | ||
// Convert to ByVal or ByValPair if possible |
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.
I've moved the code to convert to ByVal and ByValPair in here.
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.
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.
Possibly. It is obsolete when it's called from const_eval
at least.
.get_alloc(ptr.alloc_id) | ||
.expect("miri allocation never successfully created"); | ||
assert_eq!(align, alloc.align); | ||
let alloc = ecx.memory.get(ptr.alloc_id).unwrap(); |
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.
please use expect so we can find it quickly if it fails (even if the issue reported has no backtrace)
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.
I've changed this to report any miri errors then panic.
@bors r+ |
📌 Commit 41a032d has been approved by |
☀️ Test successful - status-appveyor, status-travis |
This fixes an error compiling the
immeta
0.3.6 crate. #50707 may be fixed too.r? @oli-obk