From bbaff7cc38871ed4bb40ec96061cede666d621ac Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Wed, 12 Aug 2026 15:55:41 -0400 Subject: [PATCH] fix(cuda.core): explicit exception chaining in GB_callback cleanup path 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) --- cuda_core/cuda/core/graph/_graph_builder.pyx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cuda_core/cuda/core/graph/_graph_builder.pyx b/cuda_core/cuda/core/graph/_graph_builder.pyx index d3053a7261e..8fa8b3a5247 100644 --- a/cuda_core/cuda/core/graph/_graph_builder.pyx +++ b/cuda_core/cuda/core/graph/_graph_builder.pyx @@ -931,11 +931,14 @@ cdef inline void GB_callback( if fail_tail_discovery_for_testing: raise RuntimeError("forced capture tail discovery failure") host_node = _capture_tail_node(c_stream) - except: + except BaseException as orig_exc: # CUDA added the callback, but its node cannot be identified. # Retain its owners anonymously to prevent dangling pointers. commit_status = graph_commit_attachment(prepared, NULL) - HANDLE_RETURN(commit_status) + try: + HANDLE_RETURN(commit_status) + except Exception as commit_exc: + raise commit_exc from orig_exc raise HANDLE_RETURN(graph_commit_attachment(prepared, host_node))