Skip to content

Commit 1135ad3

Browse files
committed
make shim_arg_size ptr-width-independent
1 parent 671a4b8 commit 1135ad3

File tree

3 files changed

+7
-29
lines changed

3 files changed

+7
-29
lines changed

tests/fail/shims/shim_arg_size.64bit.stderr

-15
This file was deleted.

tests/fail/shims/shim_arg_size.rs

+3-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
//@stderr-per-bitwidth
2-
31
fn main() {
42
extern "C" {
5-
// Use the wrong type(ie. not the pointer width) for the `size`
6-
// argument.
7-
#[cfg(target_pointer_width = "64")]
8-
fn malloc(size: u32) -> *mut std::ffi::c_void;
9-
10-
#[cfg(target_pointer_width = "32")]
11-
fn malloc(size: u16) -> *mut std::ffi::c_void;
3+
// Use the wrong type (ie. not `i32`) for the `c` argument.
4+
fn memchr(s: *const std::ffi::c_void, c: u8, n: usize) -> *mut std::ffi::c_void;
125
}
136

147
unsafe {
15-
let _p1 = malloc(42); //~ ERROR: Undefined Behavior: scalar size mismatch
8+
memchr(std::ptr::null(), 0, 0); //~ ERROR: Undefined Behavior: scalar size mismatch
169
};
1710
}

tests/fail/shims/shim_arg_size.32bit.stderr renamed to tests/fail/shims/shim_arg_size.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
error: Undefined Behavior: scalar size mismatch: expected 4 bytes but got 2 bytes instead
1+
error: Undefined Behavior: scalar size mismatch: expected 4 bytes but got 1 bytes instead
22
--> $DIR/shim_arg_size.rs:LL:CC
33
|
4-
LL | let _p1 = malloc(42);
5-
| ^^^^^^^^^^ scalar size mismatch: expected 4 bytes but got 2 bytes instead
4+
LL | memchr(std::ptr::null(), 0, 0);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ scalar size mismatch: expected 4 bytes but got 1 bytes instead
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9-
= note: backtrace:
9+
= note: BACKTRACE:
1010
= note: inside `main` at $DIR/shim_arg_size.rs:LL:CC
1111

1212
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

0 commit comments

Comments
 (0)