You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cuda.core: Program.__dealloc__ crashes with AttributeError when construction failed before self._options was set #2876
Program.__dealloc__ (cuda_core/cuda/core/_program.pyx:103) always calls _cleanup_debug_source(), which unconditionally reads self._options._name (line 111). self._options is only assigned inside _init at line 867. If a Program object is garbage-collected after __cinit__/__new__ but before that assignment runs — for example an exception raised during construction — self._options is still None, and _cleanup_debug_source raises AttributeError: 'NoneType' object has no attribute '_name' from inside __dealloc__. Since __dealloc__ cannot propagate an exception, this surfaces as an unraisable exception via sys.unraisablehook.
Evidence
Seen in CI as a PytestUnraisableExceptionWarning from test_program_compile_cache.py:
Exception ignored in: Program.__dealloc__
AttributeError: 'NoneType' object has no attribute '_name'
First noticed while reviewing warnings surfaced by #2759's new reporting channel; the bug predates that PR.
Suggested fix
Guard the access: if self._nvrtc_name is not None and self._options is not None and self._nvrtc_name != self._options._name:. Worth checking whether other fields __dealloc__/_cleanup_debug_source touch have the same partial-construction gap.
Activity
cuda.core: make Program.__dealloc__ safe when collected in a referenc…
cuda.core: make Program.__dealloc__ safe when collected in a referenc…