-
Notifications
You must be signed in to change notification settings - Fork 348
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
Shims should check ABI #1631
Comments
Hi, I started looking into this issue a little, and wanted to ask for some guidance before diving too much deeper in the rabbit hole. The check in if this.tcx.is_foreign_item(instance.def_id()) and call to: this.emulate_foreign_item(instance.def_id(), args, ret, unwind) do matches on function name and OS type. Since some ABI matching is done in latter function (and its inner calls), what other preliminary checks are needed in Should the arg types be matches against layouts for the target OS? Should the OS from Should a lookup of the function being interpreted be done with something like: // Check foreign allocation
let alloc_id = this.machine.extern_static_alloc_id(&this.memory, instance.def.def_id())?;
match this.memory.get_fn_alloc(alloc_id) {
Some(fn_val) => ... check fn_val matches instance?,
None => throw error,
}; Thanks in advance for any help. |
I am not sure if there are any other preliminary checks that can be done. It would have to be something that works uniformly for all functions. I do not entirely understand the purpose of the checks you are proposing, or which issues they would resolve. To do the ABI check, the first step is to adjust |
Yeah, glad I asked. Had the feeling I was going in the wrong direction 😄
I'll get started on those changes, thanks for the help. |
Add ABI argument for called function in `find_mir_or_eval_fn` and `call_extra_fn`. Useful for comparing with expected ABI in interpreters. Related to [miri/1631](rust-lang/miri#1631)
Add ABI argument to `find_mir_or_eval_fn` Add ABI argument for called function in `find_mir_or_eval_fn` and `call_extra_fn`. Useful for comparing with expected ABI in interpreters. Related to [miri/1631](rust-lang/miri#1631) r? `@RalfJung`
Resolves rust-lang#1631
Resolves rust-lang#1631
Resolves rust-lang#1631
Resolves rust-lang#1631
Our shims for missing
extern
functions now all check that the right number of arguments is being passed. However, they should also check that the right ABI is used.To do this, probably first librustc_mir needs to be changed to even propagate this information to Miri's
find_mir_or_eval_fn
.The goal is to reject buggy code like this:
The text was updated successfully, but these errors were encountered: