-
Notifications
You must be signed in to change notification settings - Fork 356
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
@rustbot author |
This comment has been minimized.
This comment has been minimized.
So now there is this weird function definition in this PR fn open(
&mut self,
args: &[OpTy<'tcx>],
fixed: &[OpTy<'tcx>; 2],
_var: &[OpTy<'tcx>],
) -> InterpResult<'tcx, Scalar> { where Since we already split fixed and var args through
It will lead to diagnostic like this: 11 | let _fd = unsafe { libc::open(name_ptr, libc::O_CREAT) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of arguments for `open(pathname, O_CREAT, ...)`: got 0, expected at least 1 Or maybe we can just ignore the fixed args and var args returned by |
Co-authored-by: Ralf Jung <[email protected]>
I would suggest to rename |
I didn't manage completely replace Lines 32 to 42 in c2a3761
I think as a miri specific extern function, the argument here shouldn't be classified as a vararg? |
@rustbot ready |
Oh dang. We have a comment in the docs for this function saying "The |
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 left some comments on the first place where you used the new infra; they apply everywhere in the PR.
@rustbot author |
Co-authored-by: Ralf Jung <[email protected]>
Alright, I can send a follow-up PR after this landed. |
src/helpers.rs
Outdated
if !abi.c_variadic { | ||
panic!("This should not be used on non-vararg function"); | ||
} |
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 am going for a panic here, but we can use other mechanism to prevent this being used at the wrong place.
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.
Which other mechanism did you have in mind?
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.
Actually yes this should not be a panic, this should be throw_ub_format!
. It is UB to call a variadic function with a non-variadic caller-side signature.
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.
t is UB to call a variadic function with a non-variadic caller-side signature.
I wonder if there is any way to test for this?
@rustbot ready |
@rustbot author |
This PR added
check_shim_variadic
to be used by variadic function shimscheck_min_vararg_count
to retrieve varargs array from slicecheck_fixed_args_count
to check if we got expected number of fixed argscc #4013