NVIDIA / NVIDIA/cuda-python

[BUG]: `register()` accepts a mismatched UUID under `python -O`

Offen
#2,697 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

triage
Vorherrschende Sprache
Cython
Sterne
3.4k
Forks
329
Ø Merge
1 T. 23 Std.
Gemergte PRs (30 T.)
116

Beschreibung

Is this a duplicate?
Type of Bug

Silent Failure

Component

cuda.core

Describe the bug

DeviceMemoryResource.register() and PinnedMemoryResource.register() check that the UUID they are given matches the resource's own with a bare assert in MP_register, so the check is absent whenever CPython runs with -O. The call then registers the resource under the other key and rewrites the resource's UUID, and mr.uuid reports the new value from then on.

How to Reproduce
import uuid
from cuda.core import Device, DeviceMemoryResource, DeviceMemoryResourceOptions
dev = Device(); dev.set_current()
mr = DeviceMemoryResource(dev, DeviceMemoryResourceOptions(ipc_enabled=True))
try:
    mr.register(uuid.UUID("00000000-0000-0000-0000-000000000001"))
except AssertionError:
    print("rejected")
else:
    print("accepted, uuid is now", mr.uuid)
$ python  repro.py
rejected
$ python -O repro.py
accepted, uuid is now 00000000-0000-0000-0000-000000000001
Expected behavior

register() should reject a UUID that is not the resource's own whether or not CPython was started with -O. Assertions are removed under -O, so the check as written does not exist in an optimized interpreter and the resource silently takes on the other key instead of raising.

Operating System

Ubuntu 26.04 LTS

nvidia-smi output
Tue Aug 25 15:01:31 2026       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 595.84                 Driver Version: 595.84         CUDA Version: 13.2     |
+-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce RTX 3050 ...    Off |   00000000:01:00.0 Off |                  N/A |
| N/A   59C    P3            749W /   30W |      11MiB /   4096MiB |      8%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

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.

Rechercherichtung

Beginne mit DeviceMemoryResource.register(), PinnedMemoryResource.register() und dem im Issue beschriebenen MP_register-Pfad. Reproduziere die Abweichung sowohl mit python als auch mit python -O und untersuche anschließend die UUID-Prüfung. Als erledigt gilt die Aufgabe, wenn beide Einstiegspunkte eine nicht übereinstimmende UUID konsistent ablehnen und die Ressourcen-UUID beibehalten.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
backend
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Aktiv
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
68/100

Neue Issues direkt in Ihr Postfach

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