Skip to content

Commit 65e4088

Browse files
committed
Didn't commit some file previously
1 parent 71bff1c commit 65e4088

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

src/shims/unix/socket.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ impl FileDescription for SocketPair {
111111
return Ok(Ok(0));
112112
}
113113

114+
// In libc socketpair, reading from a previously full socketpair buffer won't trigger
115+
// epoll notification. We want to inform the user about this inconsistency in libc and
116+
// hope to receive a bug report if someone has a use case for this.
117+
if readbuf.buf.len() == MAX_SOCKETPAIR_BUFFER_CAPACITY {
118+
throw_unsup_format!(
119+
"A previously full socketpair has been read, please submit a \
120+
bug report in https://github.com/rust-lang/miri/issues/new"
121+
);
122+
}
123+
114124
if readbuf.buf.is_empty() {
115125
if !readbuf.buf_has_writer {
116126
// Socketpair with no writer and empty buffer.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
fn main() {
2+
// Open a socketpair instance.
3+
let mut fds = [-1, -1];
4+
let mut res =
5+
unsafe { libc::socketpair(libc::AF_UNIX, libc::SOCK_STREAM, 0, fds.as_mut_ptr()) };
6+
assert_eq!(res, 0);
7+
8+
// Write until the buffer is full
9+
let array = &[0_u8; 212992];
10+
let data = array.as_slice().as_ptr();
11+
res = unsafe { libc::write(fds[0], data as *const libc::c_void, 212992).try_into().unwrap() };
12+
assert_eq!(res, 212992);
13+
let mut buf: [u8; 5] = [0; 5];
14+
unsafe { libc::read(fds[1], buf.as_mut_ptr().cast(), buf.len() as libc::size_t) };
15+
//~^ERROR: A previously full socketpair has been read
16+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: unsupported operation: A previously full socketpair has been read, please submit a bug report in https://github.com/rust-lang/miri/issues/new
2+
--> $DIR/read_from_full_socketpair.rs:LL:CC
3+
|
4+
LL | unsafe { libc::read(fds[1], buf.as_mut_ptr().cast(), buf.len() as libc::size_t) };
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ A previously full socketpair has been read, please submit a bug report in https://github.com/rust-lang/miri/issues/new
6+
|
7+
= help: this is likely not a bug in the program; it indicates that the program performed an operation that Miri does not support
8+
= note: BACKTRACE:
9+
= note: inside `main` at $DIR/read_from_full_socketpair.rs:LL:CC
10+
11+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
12+
13+
error: aborting due to 1 previous error
14+

0 commit comments

Comments
 (0)