Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[Bug]: CDI spec WriteTo leaks the temporary descriptor on save errors

オープン
#2,139 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 6 日以内に返信

@git-jxj がすでに取り組んでいます。

2026年10月13日 から。

  • #2140 @git-jxj による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
go
領域
backend

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Go
スター
4.6k
フォーク
601
平均マージ
7日 14時間
マージ済み PR(30日)
10

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

NVIDIA/nvidia-container-toolkit のほかの issue

NVIDIA/nvidia-container-toolkit の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。