-
Notifications
You must be signed in to change notification settings - Fork 349
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
Add ABI check for shims #1670
Add ABI check for shims #1670
Conversation
Thanks for the PR, @unseddd! However, we must have miscommunicated somewhere. This is not the check that I meant. In fact I think this check is redundant, since the same check is already done by the Miri core engine. I probably should give an example for what I mean. Consider this code: fn main() {
extern "Rust" {
fn malloc(size: usize) -> *mut std::ffi::c_void;
}
unsafe {
let _ = malloc(0);
};
} This code is wrong, because it calls I hope it's clearer now, and sorry for not giving a concrete example earlier. :) I will add this to the issue description as well. |
Ok, think I understand now. Honestly wasn't sure if the check(s) I PRed were correct in this context, so thanks for clarifying. Would it be correct to just do something simple like: if abi != Abi::C {
return err...;
} |
8f7917c
to
5f5c478
Compare
Sorry for the delay; I am quite busy currently so it could take a bit until I can take a closer look at what you did. It's on my queue though and will not get lost!
Well, the question is where you meant to put that check. The ABI might not be the same for all the shims we have. It probably is |
That's a bit hard to tell, which function is it talking about? If it is |
No worries, thanks for letting me know. No intention of being a nuisance 😄
I'll look into it more, then. Still need to figure out all the callers of the shim |
There seems to be some confusion about terminology here, specifically about the term "shim". I should explain what we mean by that. :)
The main entry point you have to worry about is this: miri/src/shims/foreign_items.rs Line 112 in 903bfd8
|
cbc77f5
to
62239c4
Compare
Thanks for pointing me in the right direction, that solved the failing test 😄 Sorry for the notification spam in the related issue (forgot about the commit message). This PR should be ready for review when you are. |
This function here should also check the ABI similar to what you did for Line 29 in 6fdda8a
|
@@ -504,6 +508,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx | |||
|
|||
// Architecture-specific shims | |||
"llvm.x86.sse2.pause" if this.tcx.sess.target.arch == "x86" || this.tcx.sess.target.arch == "x86_64" => { | |||
check_abi(abi, Abi::C)?; | |||
let &[] = check_arg_count(args)?; | |||
this.yield_active_thread(); |
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 just added another architecture-specific function here; can you rebase and also add the check_abi
here?
Looking great. :) Please squash the commits together, then we can merge this. (Heads-up, there might be conflicts with me resolving rust-lang/rust#81341... sorry for that.) |
☔ The latest upstream changes (presumably #1688) made this pull request unmergeable. Please resolve the merge conflicts. |
All done 😄
No worries, was an easy fix. |
3f440f7
to
4021348
Compare
📌 Commit de4eea9 has been approved by |
☀️ Test successful - checks-actions |
No problem 😄 Thanks for being patient with me during the learning process ❤️ |
Resolves #1631