make sure we check argument count everywhere
This commit is contained in:
parent
5566e3901c
commit
cd6be98852
@ -379,19 +379,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
|
||||
// Incomplete shims that we "stub out" just to get pre-main initialization code to work.
|
||||
// These shims are enabled only when the caller is in the standard library.
|
||||
| "pthread_attr_init"
|
||||
| "pthread_attr_destroy"
|
||||
| "pthread_attr_setstacksize"
|
||||
| "pthread_condattr_init"
|
||||
| "pthread_condattr_setclock"
|
||||
| "pthread_cond_init"
|
||||
| "pthread_condattr_destroy"
|
||||
| "pthread_cond_destroy" if this.frame().instance.to_string().starts_with("std::sys::unix::")
|
||||
=> {
|
||||
this.write_null(dest)?;
|
||||
}
|
||||
"pthread_attr_getguardsize" if this.frame().instance.to_string().starts_with("std::sys::unix::")
|
||||
=> {
|
||||
"pthread_attr_getguardsize"
|
||||
if this.frame().instance.to_string().starts_with("std::sys::unix::") => {
|
||||
let &[_attr, guard_size] = check_arg_count(args)?;
|
||||
let guard_size = this.deref_operand(guard_size)?;
|
||||
let guard_size_layout = this.libc_ty_layout("size_t")?;
|
||||
@ -401,11 +390,33 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
this.write_null(dest)?;
|
||||
}
|
||||
|
||||
| "pthread_attr_init"
|
||||
| "pthread_attr_destroy"
|
||||
| "pthread_condattr_init"
|
||||
| "pthread_condattr_destroy"
|
||||
| "pthread_cond_destroy"
|
||||
if this.frame().instance.to_string().starts_with("std::sys::unix::") => {
|
||||
let &[_] = check_arg_count(args)?;
|
||||
this.write_null(dest)?;
|
||||
}
|
||||
| "pthread_cond_init"
|
||||
| "pthread_attr_setstacksize"
|
||||
| "pthread_condattr_setclock"
|
||||
if this.frame().instance.to_string().starts_with("std::sys::unix::") => {
|
||||
let &[_, _] = check_arg_count(args)?;
|
||||
this.write_null(dest)?;
|
||||
}
|
||||
|
||||
| "signal"
|
||||
| "sigaction"
|
||||
| "sigaltstack"
|
||||
| "mprotect" if this.frame().instance.to_string().starts_with("std::sys::unix::")
|
||||
=> {
|
||||
if this.frame().instance.to_string().starts_with("std::sys::unix::") => {
|
||||
let &[_, _] = check_arg_count(args)?;
|
||||
this.write_null(dest)?;
|
||||
}
|
||||
| "sigaction"
|
||||
| "mprotect"
|
||||
if this.frame().instance.to_string().starts_with("std::sys::unix::") => {
|
||||
let &[_, _, _] = check_arg_count(args)?;
|
||||
this.write_null(dest)?;
|
||||
}
|
||||
|
||||
|
@ -251,22 +251,19 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
// Just fake a HANDLE
|
||||
this.write_scalar(Scalar::from_machine_isize(1, this), dest)?;
|
||||
}
|
||||
"GetModuleHandleW" if this.frame().instance.to_string().starts_with("std::sys::windows::")
|
||||
=> {
|
||||
"GetModuleHandleW" if this.frame().instance.to_string().starts_with("std::sys::windows::") => {
|
||||
#[allow(non_snake_case)]
|
||||
let &[_lpModuleName] = check_arg_count(args)?;
|
||||
// Pretend this does not exist / nothing happened, by returning zero.
|
||||
this.write_null(dest)?;
|
||||
}
|
||||
"GetProcAddress" if this.frame().instance.to_string().starts_with("std::sys::windows::")
|
||||
=> {
|
||||
"GetProcAddress" if this.frame().instance.to_string().starts_with("std::sys::windows::") => {
|
||||
#[allow(non_snake_case)]
|
||||
let &[_hModule, _lpProcName] = check_arg_count(args)?;
|
||||
// Pretend this does not exist / nothing happened, by returning zero.
|
||||
this.write_null(dest)?;
|
||||
}
|
||||
"SetConsoleTextAttribute" if this.frame().instance.to_string().starts_with("std::sys::windows::")
|
||||
=> {
|
||||
"SetConsoleTextAttribute" if this.frame().instance.to_string().starts_with("std::sys::windows::") => {
|
||||
#[allow(non_snake_case)]
|
||||
let &[_hConsoleOutput, _wAttribute] = check_arg_count(args)?;
|
||||
// Pretend these does not exist / nothing happened, by returning zero.
|
||||
@ -281,8 +278,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
| "InitializeCriticalSection"
|
||||
| "EnterCriticalSection"
|
||||
| "LeaveCriticalSection"
|
||||
| "DeleteCriticalSection" if this.frame().instance.to_string().starts_with("std::sys::windows::")
|
||||
=> {
|
||||
| "DeleteCriticalSection"
|
||||
if this.frame().instance.to_string().starts_with("std::sys::windows::") => {
|
||||
#[allow(non_snake_case)]
|
||||
let &[_lpCriticalSection] = check_arg_count(args)?;
|
||||
assert_eq!(this.get_total_thread_count()?, 1, "concurrency on Windows not supported");
|
||||
@ -290,8 +287,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
// (Windows locks are reentrant, and we have only 1 thread,
|
||||
// so not doing any futher checks here is at least not incorrect.)
|
||||
}
|
||||
"TryEnterCriticalSection" if this.frame().instance.to_string().starts_with("std::sys::windows::")
|
||||
=> {
|
||||
"TryEnterCriticalSection"
|
||||
if this.frame().instance.to_string().starts_with("std::sys::windows::") => {
|
||||
#[allow(non_snake_case)]
|
||||
let &[_lpCriticalSection] = check_arg_count(args)?;
|
||||
assert_eq!(this.get_total_thread_count()?, 1, "concurrency on Windows not supported");
|
||||
|
@ -363,6 +363,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
| "atomic_singlethreadfence_acqrel"
|
||||
| "atomic_singlethreadfence"
|
||||
=> {
|
||||
let &[] = check_arg_count(args)?;
|
||||
// we are inherently singlethreaded and singlecored, this is a nop
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user