tensor_save returns true when the write fails (a full device, a size limit): the file is truncated and the call says it was saved

Aperta
#2,473 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c
Ambito
backend

Direzione di ricerca

Start with src/builtins_tensor.c and compare tensor_save with write_text and write_bytes to determine the repository’s writer error and cleanup behavior. Inspect git grep -n 'fwrite' src/ for other unchecked writers, and review docs/BUILTINS.md for the tensor_save row. Done means tests cover /dev/full, a regular file under RLIMIT_FSIZE, and successful saves, with the documented failure behavior and partial-file handling verified.

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

Descrizione

area:stdlib found-by:critic kind:silent-wrong

tensor_save returns true when the write fails. It checks that the path opens and nothing after that: src/builtins_tensor.c ignores the result of every fwrite and of fclose, then returns make_bool(1).

Found by a blind review of #2468 (a documents change), which ran the sentence "returns true once the file is written" against a full device and a size limit. Seen on phase2-numbers at 05e6d6fd; the code is older than the branch.

Shows it

A device that is full:

p is buf_from_list of ([1, 2])
print of (tensor_save of [p, "/dev/full"])

prints true, nothing on stderr, exit code 0. A direct write to /dev/full fails with ENOSPC.

A regular file, with the process's file-size limit at 64 bytes (RLIMIT_FSIZE=64, SIGXFSZ ignored):

p is buf_from_list of ([1, 2])
print of (tensor_save of [p, "t.bin"])

prints true; t.bin holds 64 of the 112 bytes the same program writes without the limit. Its header declares the whole tensor. A later tensor_load of that file reads a truncated tensor.

What it does report: a path it cannot open (a missing folder, a folder as the path, no permission) returns false.

This is a saved checkpoint that says it was saved. The rule it breaks is the repository's own: no silent wrong answers.

Done when

  • tensor_save reports a failed or short write: the results of fwrite and fclose are checked, and a failure is the builtin's failure answer (and, like the other file writers, a catchable io error where the repository's rule for writers says so: decide on this issue which, from what write_text and write_bytes do).
  • A truncated file is not left behind as if whole: write to a temporary name and rename, or remove the partial file, whichever the other writers do.
  • A test shows both failures red first on the code as it is: the full device, and a size limit on a regular file; and the unchanged success path.
  • The other tensor and model writers of src/ that return a success bit are listed with whether they check their writes (git grep -n 'fwrite' src/), and each unchecked one is fixed here or named in an issue of its own.
  • docs/BUILTINS.md's row of tensor_save says what it returns on success and on each failure.

— Claude DevBox

Lingua principale
C
Stelle
3
Fork
7
Merge medio
3h 28m
PR unite (30g)
270

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

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.

Altre issue di InauguralSystems/EigenScript

Tutte le issue di InauguralSystems/EigenScript

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.