diff options
| author | Ralf Jung <post@ralfj.de> | 2025-02-06 17:24:44 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2025-02-06 19:16:07 +0100 |
| commit | af04c0dfa1c32799762935c25554909b1ea53b23 (patch) | |
| tree | a7d8d1cafa5fbe204de02eff8c199a8f66013217 | |
| parent | 550d2175500b806827afcd13e190ad3e1e2bdaa8 (diff) | |
| download | rust-af04c0dfa1c32799762935c25554909b1ea53b23.tar.gz rust-af04c0dfa1c32799762935c25554909b1ea53b23.zip | |
some more argument checking cleanup
12 files changed, 77 insertions, 70 deletions
diff --git a/src/tools/miri/src/helpers.rs b/src/tools/miri/src/helpers.rs index c1fed82f528..12e7d0f1a62 100644 --- a/src/tools/miri/src/helpers.rs +++ b/src/tools/miri/src/helpers.rs @@ -999,12 +999,20 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { &'a [OpTy<'tcx>; N]: TryFrom<&'a [OpTy<'tcx>]>, { self.check_abi_and_shim_symbol_clash(abi, exp_abi, link_name)?; + if abi.c_variadic { throw_ub_format!( "calling a non-variadic function with a variadic caller-side signature" ); } - check_arg_count(args) + if let Ok(ops) = args.try_into() { + return interp_ok(ops); + } + throw_ub_format!( + "incorrect number of arguments for `{link_name}`: got {}, expected {}", + args.len(), + N + ) } /// Check shim for variadic function. @@ -1020,6 +1028,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { &'a [OpTy<'tcx>; N]: TryFrom<&'a [OpTy<'tcx>]>, { self.check_abi_and_shim_symbol_clash(abi, exp_abi, link_name)?; + if !abi.c_variadic { throw_ub_format!( "calling a variadic function with a non-variadic caller-side signature" @@ -1219,7 +1228,7 @@ impl<'tcx> MiriMachine<'tcx> { } /// Check that the number of args is what we expect. -pub fn check_arg_count<'a, 'tcx, const N: usize>( +pub fn check_intrinsic_arg_count<'a, 'tcx, const N: usize>( args: &'a [OpTy<'tcx>], ) -> InterpResult<'tcx, &'a [OpTy<'tcx>; N]> where @@ -1228,7 +1237,11 @@ where if let Ok(ops) = args.try_into() { return interp_ok(ops); } - throw_ub_format!("incorrect number of arguments: got {}, expected {}", args.len(), N) + throw_ub_format!( + "incorrect number of arguments for intrinsic: got {}, expected {}", + args.len(), + N + ) } /// Check that the number of varargs is at least the minimum what we expect. diff --git a/src/tools/miri/src/intrinsics/atomic.rs b/src/tools/miri/src/intrinsics/atomic.rs index 8507b0f49de..e1e9ebb4e9d 100644 --- a/src/tools/miri/src/intrinsics/atomic.rs +++ b/src/tools/miri/src/intrinsics/atomic.rs @@ -1,7 +1,7 @@ use rustc_middle::mir::BinOp; use rustc_middle::{mir, ty}; -use self::helpers::check_arg_count; +use self::helpers::check_intrinsic_arg_count; use crate::*; pub enum AtomicOp { @@ -131,7 +131,7 @@ trait EvalContextPrivExt<'tcx>: MiriInterpCxExt<'tcx> { ) -> InterpResult<'tcx> { let this = self.eval_context_mut(); - let [place] = check_arg_count(args)?; + let [place] = check_intrinsic_arg_count(args)?; let place = this.deref_pointer(place)?; // Perform atomic load. @@ -144,7 +144,7 @@ trait EvalContextPrivExt<'tcx>: MiriInterpCxExt<'tcx> { fn atomic_store(&mut self, args: &[OpTy<'tcx>], atomic: AtomicWriteOrd) -> InterpResult<'tcx> { let this = self.eval_context_mut(); - let [place, val] = check_arg_count(args)?; + let [place, val] = check_intrinsic_arg_count(args)?; let place = this.deref_pointer(place)?; // Perform regular load. @@ -159,7 +159,7 @@ trait EvalContextPrivExt<'tcx>: MiriInterpCxExt<'tcx> { args: &[OpTy<'tcx>], atomic: AtomicFenceOrd, ) -> InterpResult<'tcx> { - let [] = check_arg_count(args)?; + let [] = check_intrinsic_arg_count(args)?; let _ = atomic; //FIXME: compiler fences are currently ignored interp_ok(()) @@ -171,7 +171,7 @@ trait EvalContextPrivExt<'tcx>: MiriInterpCxExt<'tcx> { atomic: AtomicFenceOrd, ) -> InterpResult<'tcx> { let this = self.eval_context_mut(); - let [] = check_arg_count(args)?; + let [] = check_intrinsic_arg_count(args)?; this.atomic_fence(atomic)?; interp_ok(()) } @@ -185,7 +185,7 @@ trait EvalContextPrivExt<'tcx>: MiriInterpCxExt<'tcx> { ) -> InterpResult<'tcx> { let this = self.eval_context_mut(); - let [place, rhs] = check_arg_count(args)?; + let [place, rhs] = check_intrinsic_arg_count(args)?; let place = this.deref_pointer(place)?; let rhs = this.read_immediate(rhs)?; @@ -226,7 +226,7 @@ trait EvalContextPrivExt<'tcx>: MiriInterpCxExt<'tcx> { ) -> InterpResult<'tcx> { let this = self.eval_context_mut(); - let [place, new] = check_arg_count(args)?; + let [place, new] = check_intrinsic_arg_count(args)?; let place = this.deref_pointer(place)?; let new = this.read_scalar(new)?; @@ -245,7 +245,7 @@ trait EvalContextPrivExt<'tcx>: MiriInterpCxExt<'tcx> { ) -> InterpResult<'tcx> { let this = self.eval_context_mut(); - let [place, expect_old, new] = check_arg_count(args)?; + let [place, expect_old, new] = check_intrinsic_arg_count(args)?; let place = this.deref_pointer(place)?; let expect_old = this.read_immediate(expect_old)?; // read as immediate for the sake of `binary_op()` let new = this.read_scalar(new)?; diff --git a/src/tools/miri/src/intrinsics/mod.rs b/src/tools/miri/src/intrinsics/mod.rs index bce78adcaea..ec4fdfe0bac 100644 --- a/src/tools/miri/src/intrinsics/mod.rs +++ b/src/tools/miri/src/intrinsics/mod.rs @@ -11,7 +11,7 @@ use rustc_middle::ty::{self, FloatTy}; use rustc_span::{Symbol, sym}; use self::atomic::EvalContextExt as _; -use self::helpers::{ToHost, ToSoft, check_arg_count}; +use self::helpers::{ToHost, ToSoft, check_intrinsic_arg_count}; use self::simd::EvalContextExt as _; use crate::*; @@ -104,24 +104,24 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Raw memory accesses "volatile_load" => { - let [place] = check_arg_count(args)?; + let [place] = check_intrinsic_arg_count(args)?; let place = this.deref_pointer(place)?; this.copy_op(&place, dest)?; } "volatile_store" => { - let [place, dest] = check_arg_count(args)?; + let [place, dest] = check_intrinsic_arg_count(args)?; let place = this.deref_pointer(place)?; this.copy_op(dest, &place)?; } "volatile_set_memory" => { - let [ptr, val_byte, count] = check_arg_count(args)?; + let [ptr, val_byte, count] = check_intrinsic_arg_count(args)?; this.write_bytes_intrinsic(ptr, val_byte, count, "volatile_set_memory")?; } // Memory model / provenance manipulation "ptr_mask" => { - let [ptr, mask] = check_arg_count(args)?; + let [ptr, mask] = check_intrinsic_arg_count(args)?; let ptr = this.read_pointer(ptr)?; let mask = this.read_target_usize(mask)?; @@ -137,7 +137,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // ``` // Would not be considered UB, or the other way around (`is_val_statically_known(0)`). "is_val_statically_known" => { - let [_arg] = check_arg_count(args)?; + let [_arg] = check_intrinsic_arg_count(args)?; // FIXME: should we check for validity here? It's tricky because we do not have a // place. Codegen does not seem to set any attributes like `noundef` for intrinsic // calls, so we don't *have* to do anything. @@ -146,7 +146,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } "floorf16" | "ceilf16" | "truncf16" | "roundf16" | "rintf16" => { - let [f] = check_arg_count(args)?; + let [f] = check_intrinsic_arg_count(args)?; let f = this.read_scalar(f)?.to_f16()?; let mode = match intrinsic_name { "floorf16" => Round::TowardNegative, @@ -161,7 +161,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { this.write_scalar(res, dest)?; } "floorf32" | "ceilf32" | "truncf32" | "roundf32" | "rintf32" => { - let [f] = check_arg_count(args)?; + let [f] = check_intrinsic_arg_count(args)?; let f = this.read_scalar(f)?.to_f32()?; let mode = match intrinsic_name { "floorf32" => Round::TowardNegative, @@ -176,7 +176,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { this.write_scalar(res, dest)?; } "floorf64" | "ceilf64" | "truncf64" | "roundf64" | "rintf64" => { - let [f] = check_arg_count(args)?; + let [f] = check_intrinsic_arg_count(args)?; let f = this.read_scalar(f)?.to_f64()?; let mode = match intrinsic_name { "floorf64" => Round::TowardNegative, @@ -191,7 +191,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { this.write_scalar(res, dest)?; } "floorf128" | "ceilf128" | "truncf128" | "roundf128" | "rintf128" => { - let [f] = check_arg_count(args)?; + let [f] = check_intrinsic_arg_count(args)?; let f = this.read_scalar(f)?.to_f128()?; let mode = match intrinsic_name { "floorf128" => Round::TowardNegative, @@ -216,7 +216,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { | "log10f32" | "log2f32" => { - let [f] = check_arg_count(args)?; + let [f] = check_intrinsic_arg_count(args)?; let f = this.read_scalar(f)?.to_f32()?; // Using host floats except for sqrt (but it's fine, these operations do not have // guaranteed precision). @@ -244,7 +244,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { | "log10f64" | "log2f64" => { - let [f] = check_arg_count(args)?; + let [f] = check_intrinsic_arg_count(args)?; let f = this.read_scalar(f)?.to_f64()?; // Using host floats except for sqrt (but it's fine, these operations do not have // guaranteed precision). @@ -264,7 +264,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } "fmaf32" => { - let [a, b, c] = check_arg_count(args)?; + let [a, b, c] = check_intrinsic_arg_count(args)?; let a = this.read_scalar(a)?.to_f32()?; let b = this.read_scalar(b)?.to_f32()?; let c = this.read_scalar(c)?.to_f32()?; @@ -274,7 +274,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { this.write_scalar(res, dest)?; } "fmaf64" => { - let [a, b, c] = check_arg_count(args)?; + let [a, b, c] = check_intrinsic_arg_count(args)?; let a = this.read_scalar(a)?.to_f64()?; let b = this.read_scalar(b)?.to_f64()?; let c = this.read_scalar(c)?.to_f64()?; @@ -285,7 +285,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } "fmuladdf32" => { - let [a, b, c] = check_arg_count(args)?; + let [a, b, c] = check_intrinsic_arg_count(args)?; let a = this.read_scalar(a)?.to_f32()?; let b = this.read_scalar(b)?.to_f32()?; let c = this.read_scalar(c)?.to_f32()?; @@ -300,7 +300,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { this.write_scalar(res, dest)?; } "fmuladdf64" => { - let [a, b, c] = check_arg_count(args)?; + let [a, b, c] = check_intrinsic_arg_count(args)?; let a = this.read_scalar(a)?.to_f64()?; let b = this.read_scalar(b)?.to_f64()?; let c = this.read_scalar(c)?.to_f64()?; @@ -316,7 +316,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } "powf32" => { - let [f1, f2] = check_arg_count(args)?; + let [f1, f2] = check_intrinsic_arg_count(args)?; let f1 = this.read_scalar(f1)?.to_f32()?; let f2 = this.read_scalar(f2)?.to_f32()?; // Using host floats (but it's fine, this operation does not have guaranteed precision). @@ -325,7 +325,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { this.write_scalar(res, dest)?; } "powf64" => { - let [f1, f2] = check_arg_count(args)?; + let [f1, f2] = check_intrinsic_arg_count(args)?; let f1 = this.read_scalar(f1)?.to_f64()?; let f2 = this.read_scalar(f2)?.to_f64()?; // Using host floats (but it's fine, this operation does not have guaranteed precision). @@ -335,7 +335,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } "powif32" => { - let [f, i] = check_arg_count(args)?; + let [f, i] = check_intrinsic_arg_count(args)?; let f = this.read_scalar(f)?.to_f32()?; let i = this.read_scalar(i)?.to_i32()?; // Using host floats (but it's fine, this operation does not have guaranteed precision). @@ -344,7 +344,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { this.write_scalar(res, dest)?; } "powif64" => { - let [f, i] = check_arg_count(args)?; + let [f, i] = check_intrinsic_arg_count(args)?; let f = this.read_scalar(f)?.to_f64()?; let i = this.read_scalar(i)?.to_i32()?; // Using host floats (but it's fine, this operation does not have guaranteed precision). @@ -360,7 +360,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { | "fdiv_algebraic" | "frem_algebraic" => { - let [a, b] = check_arg_count(args)?; + let [a, b] = check_intrinsic_arg_count(args)?; let a = this.read_immediate(a)?; let b = this.read_immediate(b)?; let op = match intrinsic_name { @@ -383,7 +383,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { | "fdiv_fast" | "frem_fast" => { - let [a, b] = check_arg_count(args)?; + let [a, b] = check_intrinsic_arg_count(args)?; let a = this.read_immediate(a)?; let b = this.read_immediate(b)?; let op = match intrinsic_name { @@ -427,7 +427,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } "float_to_int_unchecked" => { - let [val] = check_arg_count(args)?; + let [val] = check_intrinsic_arg_count(args)?; let val = this.read_immediate(val)?; let res = this @@ -444,7 +444,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Other "breakpoint" => { - let [] = check_arg_count(args)?; + let [] = check_intrinsic_arg_count(args)?; // normally this would raise a SIGTRAP, which aborts if no debugger is connected throw_machine_stop!(TerminationInfo::Abort(format!("trace/breakpoint trap"))) } diff --git a/src/tools/miri/src/intrinsics/simd.rs b/src/tools/miri/src/intrinsics/simd.rs index 45e316b190a..339d7161374 100644 --- a/src/tools/miri/src/intrinsics/simd.rs +++ b/src/tools/miri/src/intrinsics/simd.rs @@ -7,7 +7,9 @@ use rustc_middle::ty::layout::LayoutOf; use rustc_middle::{mir, ty}; use rustc_span::{Symbol, sym}; -use crate::helpers::{ToHost, ToSoft, bool_to_simd_element, check_arg_count, simd_element_to_bool}; +use crate::helpers::{ + ToHost, ToSoft, bool_to_simd_element, check_intrinsic_arg_count, simd_element_to_bool, +}; use crate::*; #[derive(Copy, Clone)] @@ -50,7 +52,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { | "bswap" | "bitreverse" => { - let [op] = check_arg_count(args)?; + let [op] = check_intrinsic_arg_count(args)?; let (op, op_len) = this.project_to_simd(op)?; let (dest, dest_len) = this.project_to_simd(dest)?; @@ -197,7 +199,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { => { use mir::BinOp; - let [left, right] = check_arg_count(args)?; + let [left, right] = check_intrinsic_arg_count(args)?; let (left, left_len) = this.project_to_simd(left)?; let (right, right_len) = this.project_to_simd(right)?; let (dest, dest_len) = this.project_to_simd(dest)?; @@ -288,7 +290,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } } "fma" | "relaxed_fma" => { - let [a, b, c] = check_arg_count(args)?; + let [a, b, c] = check_intrinsic_arg_count(args)?; let (a, a_len) = this.project_to_simd(a)?; let (b, b_len) = this.project_to_simd(b)?; let (c, c_len) = this.project_to_simd(c)?; @@ -352,7 +354,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { | "reduce_min" => { use mir::BinOp; - let [op] = check_arg_count(args)?; + let [op] = check_intrinsic_arg_count(args)?; let (op, op_len) = this.project_to_simd(op)?; let imm_from_bool = @@ -415,7 +417,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { | "reduce_mul_ordered" => { use mir::BinOp; - let [op, init] = check_arg_count(args)?; + let [op, init] = check_intrinsic_arg_count(args)?; let (op, op_len) = this.project_to_simd(op)?; let init = this.read_immediate(init)?; @@ -433,7 +435,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { this.write_immediate(*res, dest)?; } "select" => { - let [mask, yes, no] = check_arg_count(args)?; + let [mask, yes, no] = check_intrinsic_arg_count(args)?; let (mask, mask_len) = this.project_to_simd(mask)?; let (yes, yes_len) = this.project_to_simd(yes)?; let (no, no_len) = this.project_to_simd(no)?; @@ -455,7 +457,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } // Variant of `select` that takes a bitmask rather than a "vector of bool". "select_bitmask" => { - let [mask, yes, no] = check_arg_count(args)?; + let [mask, yes, no] = check_intrinsic_arg_count(args)?; let (yes, yes_len) = this.project_to_simd(yes)?; let (no, no_len) = this.project_to_simd(no)?; let (dest, dest_len) = this.project_to_simd(dest)?; @@ -529,7 +531,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } // Converts a "vector of bool" into a bitmask. "bitmask" => { - let [op] = check_arg_count(args)?; + let [op] = check_intrinsic_arg_count(args)?; let (op, op_len) = this.project_to_simd(op)?; let bitmask_len = op_len.next_multiple_of(8); if bitmask_len > 64 { @@ -577,7 +579,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } } "cast" | "as" | "cast_ptr" | "expose_provenance" | "with_exposed_provenance" => { - let [op] = check_arg_count(args)?; + let [op] = check_intrinsic_arg_count(args)?; let (op, op_len) = this.project_to_simd(op)?; let (dest, dest_len) = this.project_to_simd(dest)?; @@ -634,7 +636,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } } "shuffle_generic" => { - let [left, right] = check_arg_count(args)?; + let [left, right] = check_intrinsic_arg_count(args)?; let (left, left_len) = this.project_to_simd(left)?; let (right, right_len) = this.project_to_simd(right)?; let (dest, dest_len) = this.project_to_simd(dest)?; @@ -664,7 +666,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } } "shuffle" => { - let [left, right, index] = check_arg_count(args)?; + let [left, right, index] = check_intrinsic_arg_count(args)?; let (left, left_len) = this.project_to_simd(left)?; let (right, right_len) = this.project_to_simd(right)?; let (index, index_len) = this.project_to_simd(index)?; @@ -695,7 +697,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } } "gather" => { - let [passthru, ptrs, mask] = check_arg_count(args)?; + let [passthru, ptrs, mask] = check_intrinsic_arg_count(args)?; let (passthru, passthru_len) = this.project_to_simd(passthru)?; let (ptrs, ptrs_len) = this.project_to_simd(ptrs)?; let (mask, mask_len) = this.project_to_simd(mask)?; @@ -721,7 +723,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } } "scatter" => { - let [value, ptrs, mask] = check_arg_count(args)?; + let [value, ptrs, mask] = check_intrinsic_arg_count(args)?; let (value, value_len) = this.project_to_simd(value)?; let (ptrs, ptrs_len) = this.project_to_simd(ptrs)?; let (mask, mask_len) = this.project_to_simd(mask)?; @@ -741,7 +743,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } } "masked_load" => { - let [mask, ptr, default] = check_arg_count(args)?; + let [mask, ptr, default] = check_intrinsic_arg_count(args)?; let (mask, mask_len) = this.project_to_simd(mask)?; let ptr = this.read_pointer(ptr)?; let (default, default_len) = this.project_to_simd(default)?; @@ -767,7 +769,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } } "masked_store" => { - let [mask, ptr, vals] = check_arg_count(args)?; + let [mask, ptr, vals] = check_intrinsic_arg_count(args)?; let (mask, mask_len) = this.project_to_simd(mask)?; let ptr = this.read_pointer(ptr)?; let (vals, vals_len) = this.project_to_simd(vals)?; diff --git a/src/tools/miri/src/shims/panic.rs b/src/tools/miri/src/shims/panic.rs index 83f331bb173..fc58d88591f 100644 --- a/src/tools/miri/src/shims/panic.rs +++ b/src/tools/miri/src/shims/panic.rs @@ -15,7 +15,7 @@ use rustc_abi::ExternAbi; use rustc_middle::{mir, ty}; use rustc_target::spec::PanicStrategy; -use self::helpers::check_arg_count; +use self::helpers::check_intrinsic_arg_count; use crate::*; /// Holds all of the relevant data for when unwinding hits a `try` frame. @@ -77,7 +77,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // a pointer to `Box<dyn Any + Send + 'static>`. // Get all the arguments. - let [try_fn, data, catch_fn] = check_arg_count(args)?; + let [try_fn, data, catch_fn] = check_intrinsic_arg_count(args)?; let try_fn = this.read_pointer(try_fn)?; let data = this.read_immediate(data)?; let catch_fn = this.read_pointer(catch_fn)?; diff --git a/src/tools/miri/src/shims/unix/linux_like/sync.rs b/src/tools/miri/src/shims/unix/linux_like/sync.rs index 280bee4800f..86e8b57824c 100644 --- a/src/tools/miri/src/shims/unix/linux_like/sync.rs +++ b/src/tools/miri/src/shims/unix/linux_like/sync.rs @@ -13,14 +13,6 @@ pub fn futex<'tcx>( varargs: &[OpTy<'tcx>], dest: &MPlaceTy<'tcx>, ) -> InterpResult<'tcx> { - // The amount of arguments used depends on the type of futex operation. - // The full futex syscall takes six arguments (excluding the syscall - // number), which is also the maximum amount of arguments a linux syscall - // can take on most architectures. - // However, not all futex operations use all six arguments. The unused ones - // may or may not be left out from the `syscall()` call. - // Therefore we don't use `check_arg_count` here, but only check for the - // number of arguments to fall within a range. let [addr, op, val] = check_min_vararg_count("`syscall(SYS_futex, ...)`", varargs)?; // The first three arguments (after the syscall number itself) are the same to all futex operations: diff --git a/src/tools/miri/tests/fail/function_calls/check_arg_count_abort.rs b/src/tools/miri/tests/fail/function_calls/check_arg_count_abort.rs index 967a78bf831..db7bd223bd4 100644 --- a/src/tools/miri/tests/fail/function_calls/check_arg_count_abort.rs +++ b/src/tools/miri/tests/fail/function_calls/check_arg_count_abort.rs @@ -5,6 +5,6 @@ fn main() { unsafe { abort(1); - //~^ ERROR: Undefined Behavior: incorrect number of arguments: got 1, expected 0 + //~^ ERROR: Undefined Behavior: incorrect number of arguments for `abort`: got 1, expected 0 } } diff --git a/src/tools/miri/tests/fail/function_calls/check_arg_count_abort.stderr b/src/tools/miri/tests/fail/function_calls/check_arg_count_abort.stderr index 687d0538b3c..3c81ba4e141 100644 --- a/src/tools/miri/tests/fail/function_calls/check_arg_count_abort.stderr +++ b/src/tools/miri/tests/fail/function_calls/check_arg_count_abort.stderr @@ -1,8 +1,8 @@ -error: Undefined Behavior: incorrect number of arguments: got 1, expected 0 +error: Undefined Behavior: incorrect number of arguments for `abort`: got 1, expected 0 --> tests/fail/function_calls/check_arg_count_abort.rs:LL:CC | LL | abort(1); - | ^^^^^^^^ incorrect number of arguments: got 1, expected 0 + | ^^^^^^^^ incorrect number of arguments for `abort`: got 1, expected 0 | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information diff --git a/src/tools/miri/tests/fail/function_calls/check_arg_count_too_few_args.rs b/src/tools/miri/tests/fail/function_calls/check_arg_count_too_few_args.rs index 223c95ffca4..41aebea2d8a 100644 --- a/src/tools/miri/tests/fail/function_calls/check_arg_count_too_few_args.rs +++ b/src/tools/miri/tests/fail/function_calls/check_arg_count_too_few_args.rs @@ -4,6 +4,6 @@ fn main() { } unsafe { - let _ = malloc(); //~ ERROR: Undefined Behavior: incorrect number of arguments: got 0, expected 1 + let _ = malloc(); //~ ERROR: Undefined Behavior: incorrect number of arguments for `malloc`: got 0, expected 1 }; } diff --git a/src/tools/miri/tests/fail/function_calls/check_arg_count_too_few_args.stderr b/src/tools/miri/tests/fail/function_calls/check_arg_count_too_few_args.stderr index d778eae64fa..eacd4045ae0 100644 --- a/src/tools/miri/tests/fail/function_calls/check_arg_count_too_few_args.stderr +++ b/src/tools/miri/tests/fail/function_calls/check_arg_count_too_few_args.stderr @@ -1,8 +1,8 @@ -error: Undefined Behavior: incorrect number of arguments: got 0, expected 1 +error: Undefined Behavior: incorrect number of arguments for `malloc`: got 0, expected 1 --> tests/fail/function_calls/check_arg_count_too_few_args.rs:LL:CC | LL | let _ = malloc(); - | ^^^^^^^^ incorrect number of arguments: got 0, expected 1 + | ^^^^^^^^ incorrect number of arguments for `malloc`: got 0, expected 1 | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information diff --git a/src/tools/miri/tests/fail/function_calls/check_arg_count_too_many_args.rs b/src/tools/miri/tests/fail/function_calls/check_arg_count_too_many_args.rs index 7ee9c40bf7a..1f5c509c666 100644 --- a/src/tools/miri/tests/fail/function_calls/check_arg_count_too_many_args.rs +++ b/src/tools/miri/tests/fail/function_calls/check_arg_count_too_many_args.rs @@ -4,6 +4,6 @@ fn main() { } unsafe { - let _ = malloc(1, 2); //~ ERROR: Undefined Behavior: incorrect number of arguments: got 2, expected 1 + let _ = malloc(1, 2); //~ ERROR: Undefined Behavior: incorrect number of arguments for `malloc`: got 2, expected 1 }; } diff --git a/src/tools/miri/tests/fail/function_calls/check_arg_count_too_many_args.stderr b/src/tools/miri/tests/fail/function_calls/check_arg_count_too_many_args.stderr index dfec2a86287..42d5e98c01a 100644 --- a/src/tools/miri/tests/fail/function_calls/check_arg_count_too_many_args.stderr +++ b/src/tools/miri/tests/fail/function_calls/check_arg_count_too_many_args.stderr @@ -1,8 +1,8 @@ -error: Undefined Behavior: incorrect number of arguments: got 2, expected 1 +error: Undefined Behavior: incorrect number of arguments for `malloc`: got 2, expected 1 --> tests/fail/function_calls/check_arg_count_too_many_args.rs:LL:CC | LL | let _ = malloc(1, 2); - | ^^^^^^^^^^^^ incorrect number of arguments: got 2, expected 1 + | ^^^^^^^^^^^^ incorrect number of arguments for `malloc`: got 2, expected 1 | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information |
