Skip to content

fix(cuda.core): explicit exception chaining in GB_callback cleanup path - #2610

Open
mdboom wants to merge 1 commit into
NVIDIA:mainfrom
mdboom:raise-from
Open

fix(cuda.core): explicit exception chaining in GB_callback cleanup path#2610
mdboom wants to merge 1 commit into
NVIDIA:mainfrom
mdboom:raise-from

Conversation

@mdboom

@mdboom mdboom commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • In GB_callback, when _capture_tail_node fails the handler calls graph_commit_attachment and HANDLE_RETURN as anonymous-owner cleanup. If that HANDLE_RETURN raises, Python implicitly sets __context__ to the caught exception, producing a confusing "During handling of the above exception, another exception occurred" traceback that buries the real CUDA error.
  • Changed except: to except BaseException as orig_exc: and wrapped the cleanup HANDLE_RETURN in a try/except that uses raise commit_exc from orig_exc to make the causal relationship explicit.

Test plan

  • Existing graph builder tests (pytest cuda_core/tests/) cover the _capture_tail_node path including _capture_callback_with_tail_failure_for_testing
  • Verify the commit failure path emits a clean traceback with explicit exception chaining

🤖 Generated with Claude Code

When _capture_tail_node fails, the anonymous-commit cleanup calls
HANDLE_RETURN inside the except handler. If that HANDLE_RETURN also
raises, Python's implicit chaining would emit a confusing "During
handling of the above exception, another exception occurred" message
that buries the real CUDA error. Make the causal relationship explicit
with `raise commit_exc from orig_exc`.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@mdboom mdboom added this to the cuda.core next milestone Aug 12, 2026
@mdboom mdboom added bug Something isn't working cuda.core Everything related to the cuda.core module labels Aug 12, 2026
@mdboom mdboom self-assigned this Aug 12, 2026
@github-actions

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cuda.core Everything related to the cuda.core module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant