NVIDIA / NVIDIA/cuda-python

[BUG]: VirtualMemoryResource: four pre-existing defects (grow-rollback access loss, dead fast path, finalizer warnings, handle_type docstring)

Offen
#2,388 1 Kommentar 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@aryanputta arbeitet bereits daran.

Seit 23.7.2026.

bug cuda.core
Vorherrschende Sprache
Cython
Sterne
3.4k
Forks
329
Ø Merge
1 T. 21 Std.
Gemergte PRs (30 T.)
113

Beschreibung

Component

cuda.core

What happened?

Four pre-existing defects in VirtualMemoryResource, all found while verifying #2235 (verification details in https://github.com/NVIDIA/cuda-python/pull/2235#pullrequestreview-4728931983); none are introduced by that PR.

  1. Rollback of a failed grow loses access grants — if modify_allocation() fails after the old range has been remapped (slow path), the _remap_old rollback restores the mapping at the original address but never re-applies the access descriptors, so the rolled-back buffer faults on its next access until cuMemSetAccess is re-run. Reproduced on main by forcing cuMemSetAccess to fail during a grow. Likely fix: _remap_old should re-apply the resource's access descriptors to the old range (best-effort, matching the remap itself).

  2. The grow fast path is dead codethis check compares a CUdeviceptr against a plain int, and CUdeviceptr(x) == x is always False, so modify_allocation() always takes the slow path (full re-reserve + remap, base pointer changes) even when the driver granted the exact contiguous extension address. Fix: compare int(new_ptr).

  3. Warning spam after every slow-path grow — the slow path calls buf._clear() so the old buffer's destructor won't double-free, but the destructor still calls deallocate(), emitting Warning: mr.deallocate() failed during Buffer destruction: CUDA_ERROR_INVALID_VALUE at GC after each grow. (Adjacent to the existing TODO referencing #2049.)

  4. handle_type docstring is wrongthe docstring claims posix_fd is "required for cuMemRetainAllocationHandle"; retain works on handle_type=None allocations (verified on driver r595) and the driver documentation has no such restriction.

-- Leo's bot

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.