cuda.core: reject operations on closed resource objects - #2635
Open
Andy-Jost wants to merge 3 commits into
Open
Conversation
|
Andy-Jost
commented
Aug 14, 2026
Comment on lines
133
to
+138
| q_bc.put(buffer) | ||
| buffer.close() | ||
|
|
||
| # Wait for C to receive before exiting. | ||
| # Queue serialization runs in a feeder thread. Keep the buffer open | ||
| # until C has received it and the parent releases this process. | ||
| event_b.wait(timeout=CHILD_TIMEOUT_SEC) | ||
| buffer.close() |
Contributor
Author
There was a problem hiding this comment.
This fixes a latent bug. multiprocessing.Queue.put requires its argument to remain valid until received.
Andy-Jost
force-pushed
the
ajost/closed-resource-validation
branch
from
August 14, 2026 20:29
0539baa to
31f74c3
Compare
Add consistent liveness checks so closed handles cannot reach CUDA as valid resources, including graph and cross-object operations.
The allocation-handle constructor is intentionally unsupported on Windows, so limit its close-state test to supported platforms.
Andy-Jost
force-pushed
the
ajost/closed-resource-validation
branch
from
August 14, 2026 22:51
31f74c3 to
84db682
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
closes #2627
Add a consistent closed-state contract across
cuda.coreresource objects so released native handles are rejected before reaching CUDA. Resource objects now expose their live state through Boolean conversion, active methods validate their own state and accepted resource arguments, and graph objects distinguish valid virtual entry nodes from destroyed or invalid objects.Stream_accept()now rejects closed streams and graph builders. This also makesBuffer.set_deallocation_stream()andBuffer.close(stream=...)reject a closed stream without replacing the buffer's saved deallocation recipe. Closing CUDA default-stream tokens remains a no-op.The same validation covers events, buffers, memory pools, IPC handles, contexts, compiler resources, graphs, arrays, textures, surfaces, and graphics resources. Tests cover Boolean state, idempotent cleanup, safe inspection, cross-object validation, graph invalidation, and deallocation-stream failure atomicity.
Checklist