nodejs / nodejs/node

Nonsense UNKNOWN error when writing large buffers with fs.writev

Aperta
#40,779 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

fs
Lingua principale
JavaScript
Stelle
122k
Fork
37.3k
Merge medio
4g 2h
PR unite (30g)
283

Descrizione

Version

14.18.1

Platform

Linux ops 5.11.0-1021-gcp #23~20.04.1-Ubuntu SMP Fri Oct 1 19:04:32 UTC 2021 x86_64 x86_64 x86_64 GNU/Linu

Subsystem

fs

What steps will reproduce the bug?
const fs = require("fs");
const fd = fs.openSync("./test.dat", fs.constants.O_WRONLY | fs.constants.O_CREAT, 0o666);
const bufs = [Buffer.alloc(0x7FFFFFFF + 1)];
fs.writevSync(fd, bufs, 0);

This throws

Uncaught Error: UNKNOWN: unknown error, write
    at Object.writevSync (fs.js:749:3) {
  errno: -2147483648,
  syscall: 'write',
  code: 'UNKNOWN'
}

That errno is 0x7fffffff + 1 wrapped around.

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior?

Should either work, since pwritev(2) works (I don't know if it has a limit less than SSIZE_MAX), or report a proper error before making the syscall. I did the latter recently for fs.write in c4e7dca8f30ff89b42e96fb8819558ed518a72dd. It would be nice if large files actually worked, but the best fix for that would require a new libuv function.

What do you see instead?

No response

Additional information

No response

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia da fs.writevSync in fs.js e confronta la gestione dei relativi argomenti con la validazione di fs.write a cui fa riferimento il commit c4e7dca8f30ff89b42e96fb8819558ed518a72dd. Riproduci il caso del buffer di grandi dimensioni su Linux, quindi determina se il comportamento definitivo debba rifiutare la richiesta con un errore appropriato prima della syscall oppure supportare il buffer più grande tramite libuv.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, node.js
Ambito
backend, operating-systems
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.