-
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
Check fixed args number for variadic function #4122
base: master
Are you sure you want to change the base?
Conversation
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 squash
@@ -236,6 +237,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { | |||
"open" | "open64" => { | |||
// `open` is variadic, the third argument is only present when the second argument has O_CREAT (or on linux O_TMPFILE, but miri doesn't support that) set | |||
this.check_abi_and_shim_symbol_clash(abi, Conv::C , link_name)?; | |||
this.check_fixed_args_count("open/open64", abi, 2)?; |
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.
Now it's still fairly easy to forget to call check_fixed_args_count
.
So instead, please add a new this.check_shim_variadic
that is a lot like check_shim
but returns something like (&'a [OpTy<'tcx>; N], &'a [OpTy<'tcx>])
where the "fixed" arguments are mapped to the array and the variadic ones are returned in the slice.
When this is all done, check_abi_and_shim_symbol_clash
should never be called in a shim; each shim should call check_shim
or check_shim_variadic
.
) -> InterpResult<'tcx> { | ||
if abi.fixed_count != expected_count { | ||
throw_ub_format!( | ||
"incorrect number of fixed args for `{name}`: got {}, expected {expected_count}", |
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.
"incorrect number of fixed args for `{name}`: got {}, expected {expected_count}", | |
"incorrect number of fixed arguments for variadic function `{name}`: got {}, expected {expected_count}", |
@rustbot author |
cc #4013
@rustbot ready