Skip to content

Commit bbaff7c

Browse files
mdboomclaude
andcommitted
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) <noreply@anthropic.com>
1 parent a14557b commit bbaff7c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

cuda_core/cuda/core/graph/_graph_builder.pyx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,11 +931,14 @@ cdef inline void GB_callback(
931931
if fail_tail_discovery_for_testing:
932932
raise RuntimeError("forced capture tail discovery failure")
933933
host_node = _capture_tail_node(c_stream)
934-
except:
934+
except BaseException as orig_exc:
935935
# CUDA added the callback, but its node cannot be identified.
936936
# Retain its owners anonymously to prevent dangling pointers.
937937
commit_status = graph_commit_attachment(prepared, NULL)
938-
HANDLE_RETURN(commit_status)
938+
try:
939+
HANDLE_RETURN(commit_status)
940+
except Exception as commit_exc:
941+
raise commit_exc from orig_exc
939942
raise
940943
HANDLE_RETURN(graph_commit_attachment(prepared, host_node))
941944

0 commit comments

Comments
 (0)