diff options
| author | bors <bors@rust-lang.org> | 2024-08-24 08:01:37 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-08-24 08:01:37 +0000 |
| commit | 17659eb40fdada377985ee1a14d649c4ebe21967 (patch) | |
| tree | f8df9f06584dfc0e2082815814ae56e329295baf /src/tools | |
| parent | b8c02eb11eaac24e56ef718040eb83c304125ac6 (diff) | |
| parent | 7f968ba98d853f29042c8e917d2d8047043551f8 (diff) | |
| download | rust-17659eb40fdada377985ee1a14d649c4ebe21967.tar.gz rust-17659eb40fdada377985ee1a14d649c4ebe21967.zip | |
Auto merge of #3840 - RalfJung:pipe-to-array, r=RalfJung
fix calling pipe, pipe2, socketpair with a pointer-to-array Fixes https://github.com/rust-lang/miri/issues/3839
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/miri/src/shims/unix/unnamed_socket.rs | 2 | ||||
| -rw-r--r-- | src/tools/miri/tests/pass-dep/libc/libc-pipe.rs | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/tools/miri/src/shims/unix/unnamed_socket.rs b/src/tools/miri/src/shims/unix/unnamed_socket.rs index 745f27398d0..127aef29244 100644 --- a/src/tools/miri/src/shims/unix/unnamed_socket.rs +++ b/src/tools/miri/src/shims/unix/unnamed_socket.rs @@ -339,7 +339,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { ) -> InterpResult<'tcx, Scalar> { let this = self.eval_context_mut(); - let pipefd = this.deref_pointer(pipefd)?; + let pipefd = this.deref_pointer_as(pipefd, this.machine.layouts.i32)?; let flags = match flags { Some(flags) => this.read_scalar(flags)?.to_i32()?, None => 0, diff --git a/src/tools/miri/tests/pass-dep/libc/libc-pipe.rs b/src/tools/miri/tests/pass-dep/libc/libc-pipe.rs index 5dff612bd89..90dbd888392 100644 --- a/src/tools/miri/tests/pass-dep/libc/libc-pipe.rs +++ b/src/tools/miri/tests/pass-dep/libc/libc-pipe.rs @@ -6,6 +6,7 @@ fn main() { test_pipe(); test_pipe_threaded(); test_race(); + test_pipe_array(); } fn test_pipe() { @@ -97,3 +98,13 @@ fn test_race() { thread::yield_now(); thread1.join().unwrap(); } + +fn test_pipe_array() { + // Declare `pipe` to take an array rather than a `*mut i32`. + extern "C" { + fn pipe(pipefd: &mut [i32; 2]) -> i32; + } + + let mut fds: [i32; 2] = [0; 2]; + assert_eq!(unsafe { pipe(&mut fds) }, 0); +} |
