splice and sendfile lose input into a nonblocking pipe
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- c
- Ambito
- operating-systems
Direzione di ricerca
Start in src/syscall/io.c with sys_splice, splice_drain_chunk, copy_fd_range, and io_rewind_unsent; compare their behavior with the existing SPLICE_F_NONBLOCK handling from #463. Reproduce the reported nonblocking-pipe, sendfile-pipe-input, and interrupted blocking-socket cases against Linux and elfuse. Done means no input is consumed unless written, sendfile rejects pipe input with EINVAL, and splice reports the expected result when interrupted.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
splice and sendfile lose input when the output is a pipe the guest set O_NONBLOCK. The emulation reads a whole chunk from the input before it writes it (sys_splice and splice_drain_chunk, copy_fd_range for sendfile in src/syscall/io.c). When the nonblocking write places only part of the chunk, the rest has already been consumed, and io_rewind_unsent cannot hand it back to a pipe or socket input.
Measured with a static aarch64 probe: pipe a holds 8 KiB, pipe b has O_NONBLOCK set by the guest and 4 KiB of free room, then the probe calls splice(a[0], NULL, b[1], NULL, 8192, 0) and, in a second run, sendfile(b[1], a[0], NULL, 8192).
| Call | Linux (qemu) | elfuse main (e9fdbbb) |
|---|---|---|
| splice | returns 4096, 4 KiB still in a |
returns 4096, a empty: 4 KiB lost |
| sendfile | -1, EINVAL (a pipe input is refused) | returns 4096, a empty: 4 KiB lost |
The sendfile row has a second difference: Linux refuses a pipe as the sendfile input, and elfuse accepts it.
#463 fixed the same loss for SPLICE_F_NONBLOCK: a pipe output is polled for POLLOUT before each read and the chunk is capped at PIPE_BUF, since a ready macOS pipe has at least that much free. The O_NONBLOCK case still reaches the old path.
A blocking socket output has a related gap. Linux ignores SPLICE_F_NONBLOCK for a socket output and follows the socket's own O_NONBLOCK, so the call blocks there too. Measured: splice(pipe_with_5_bytes, NULL, full_blocking_af_unix_socket, NULL, 5, SPLICE_F_NONBLOCK) with a 2 s alarm and a handler returns -1 with EINTR on Linux under qemu. elfuse never returns: the chunk has already been read from the pipe and cannot be put back, so splice_drain_chunk keeps retrying the write instead of reporting the signal.
Goal: when the output cannot take a whole chunk without blocking, splice and sendfile read only what the output can take and report what moved, so no input byte is consumed without being written. sendfile refuses a pipe input with EINVAL, as Linux does.
- Lingua principale
- C
- Stelle
- 287
- Fork
- 33
- Merge medio
- 2g 17h
- PR unite (30g)
- 18
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di sysprog21/elfuse
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di sysprog21/elfuse
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
libreswan/libreswan#3185 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
[SDL3pp] update to 0.12.0Apertacategory:port-update
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
-
[InstCombine] 23.x folds 0.0 * (0.0 / x) to 0.0 when x may be zero (fixed on main by #202482)Apertallvm:instcombine
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
llvm/llvm-project#246503 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno