-
Notifications
You must be signed in to change notification settings - Fork 353
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
ensure that integers cast to pointers will never point at a valid alloc, not even the zst alloc #81
Changes from 1 commit
921f5af
b2d476e
1c40fb0
d42a7d0
75f56eb
f71c31c
2c34d65
511fa40
4a39c22
14ff641
13f22f8
f77a0ab
e2091ff
1549c2d
4748587
5ee75c0
1c5c6cd
64155ff
fd68670
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,7 +73,7 @@ impl Pointer { | |
// FIXME(solson): Integer pointers should use u64, not usize. Target pointers can be larger | ||
// than host usize. | ||
pub fn from_int(i: usize) -> Self { | ||
Pointer::new(ZST_ALLOC_ID, i) | ||
Pointer::new(NEVER_ALLOC_ID, i) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so I did this change to fix the assume bug, which then caused drop impls to fail: https://github.com/solson/miri/pull/81/files#diff-8f4a840e817b018e1d74153888641b27L642 and int to pointer cast error messages to show up as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems fine. I might have a plan to refactor |
||
} | ||
|
||
pub fn zst_ptr() -> Self { | ||
|
@@ -290,7 +290,7 @@ impl<'a, 'tcx> Memory<'a, 'tcx> { | |
Some(alloc) => Ok(alloc), | ||
None => match self.functions.get(&id) { | ||
Some(_) => Err(EvalError::DerefFunctionPointer), | ||
None if id == ZST_ALLOC_ID => Err(EvalError::InvalidMemoryAccess), | ||
None if id == NEVER_ALLOC_ID || id == ZST_ALLOC_ID => Err(EvalError::InvalidMemoryAccess), | ||
None => Err(EvalError::DanglingPointerDeref), | ||
} | ||
} | ||
|
@@ -302,7 +302,7 @@ impl<'a, 'tcx> Memory<'a, 'tcx> { | |
Some(alloc) => Ok(alloc), | ||
None => match self.functions.get(&id) { | ||
Some(_) => Err(EvalError::DerefFunctionPointer), | ||
None if id == ZST_ALLOC_ID => Err(EvalError::InvalidMemoryAccess), | ||
None if id == NEVER_ALLOC_ID || id == ZST_ALLOC_ID => Err(EvalError::InvalidMemoryAccess), | ||
None => Err(EvalError::DanglingPointerDeref), | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
vec![()].into_iter(); | ||
} |
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 doesn't this apply to general pointers casted to function pointers any more? The name
InvalidFunctionPointer
seems too general for the new error message.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.
@oli-obk pinging to make sure you don't miss this.
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.
Nothing changed here, the error message was outdated way before this pr, we can adjust the variant name to match that
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.
What kind of error do we actually get when treating a regular pointer as a function 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.
We can't do
transmute(42)
because primvals panic in some cases right now. I think we should eliminate theexpect
functions and have thetry
functions return anEvalResult
instead.