[Bug]: CDI spec WriteTo leaks the temporary descriptor on save errors
I maintainer di solito rispondono entro 6 giorni
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 35/100
Direzione di ricerca
Start at spec.Interface.WriteTo in the pkg/nvcdi/spec package and trace the temporary-file cleanup and close paths when saving fails. The issue gives a reproducer using an invalid CDI version and io.Discard; use it to confirm that failed writes close the descriptor and remove the temporary file. An open linked pull request (#2140) is already addressing this issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
spec.Interface.WriteTo leaves the temporary file descriptor open when saving the CDI specification fails. The temporary pathname is removed, but the descriptor is only reclaimed by Go's file finalizer.
On current main (023f35906ee23384b48dc3db3f2d1fb75d29f6b0), eight failed writes leave eight open, deleted nvcdi-spec-*.yaml descriptors when garbage collection is disabled. This affects callers that reuse the public library after a validation or filesystem error.
To Reproduce
Run the following from a module that imports the toolkit:
package main
import (
"io"
"runtime/debug"
"github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/spec"
)
func main() {
debug.SetGCPercent(-1) // Make descriptor cleanup independent of finalizers.
s, err := spec.New(spec.WithVersion("invalid"))
if err != nil {
panic(err)
}
for i := 0; i < 8; i++ {
_, err := s.WriteTo(io.Discard)
if err == nil {
panic("expected CDI validation failure")
}
}
select {} // Inspect /proc/<pid>/fd in another terminal.
}
Each failed write reports failed to write spec: invalid CDI Spec: invalid version "invalid". /proc/<pid>/fd contains eight temporary CDI files with the (deleted) suffix. No temporary pathname remains on disk.
Expected behavior
Every return from WriteTo should close the temporary file descriptor, including failures before the existing explicit tmpFile.Close() call. The original save error and temporary-file cleanup should be preserved.
Environment
- Toolkit: current main at
023f35906ee23384b48dc3db3f2d1fb75d29f6b0 - Linux amd64, Go 1.26.0
- Reproduction uses the public Go API; GPU, driver, and container-runtime operations are not involved.
Additional information
The error is reproducible without GPU hardware. I plan to add a focused regression that separately checks open descriptors and remaining temporary files, and ensure the temporary descriptor is closed on the save-error path.
- Lingua principale
- Go
- Stelle
- 4.6k
- Fork
- 601
- Merge medio
- 7g 14h
- PR unite (30g)
- 10
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un 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 NVIDIA/nvidia-container-toolkit
-
Address TODO comments in internal/platform-support/dgpu/dgpu.goForse già presa @truongbo17 l’ha presa 16 giorni fa. Apertadsx-ws-0930 good-first-issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
NVIDIA/nvidia-container-toolkit#2114 · 1 commento ·
I maintainer di solito rispondono entro 6 giorni
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 78/100
NVIDIA/nvidia-container-toolkit#2147 ·
I maintainer di solito rispondono entro 6 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 47/100
NVIDIA/nvidia-container-toolkit#2137 ·
I maintainer di solito rispondono entro 6 giorni
-
[Bug]: containerd cleanup removes imports for unrelated drop-insForse già presa @git-jxj l’ha presa 7 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
NVIDIA/nvidia-container-toolkit#2134 ·
I maintainer di solito rispondono entro 6 giorni
-
[Bug]: create-symlinks and update-ldcache hooks fail container create when the container rootfs is read-onlyForse già presa @sahanasreenath l’ha presa 9 giorni fa. Aperta
Difficoltà 3/5 Mezza giornata Idoneità per principianti 25/100
NVIDIA/nvidia-container-toolkit#2131 · 2 commenti ·
I maintainer di solito rispondono entro 6 giorni
Tutte le issue di NVIDIA/nvidia-container-toolkit
Issue simili
-
Chained slog With calls discard previously bound attributesForse già presa @yuefdev l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
[scanner] TestAgentNowLineStates hard-fails instead of degrading when node is off PATHForse già presa @arteeh l’ha presa oggi. Apertaagent/scanner ci help wanted kind/test
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
hivecommons/hive#12924 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Gentleman-Programming/engram#1940 ·
I maintainer di solito rispondono entro 1 giorno
-
area: go-workers help wanted tech debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
[exporter/splunkhec] Oversized metric event causes subsequent valid metrics to be droppedForse già presa @harshkoli1255 l’ha presa oggi. Apertabug exporter/splunkhec needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
open-telemetry/opentelemetry-collector-contrib#52142 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno