Repository navigation
Return owning any_resource from set_per_device_resource_ref - #2271
Merged
bdice merged 1 commit intoMar 4, 2026
Merged
Conversation
The set/reset functions returned device_async_resource_ref (non-owning) to the previous resource, but the underlying any_resource in the map was immediately overwritten, leaving the returned ref dangling. This is UB that happens to be masked by SBO for small resource types like cuda_memory_resource. Return cuda::mr::any_resource<cuda::mr::device_accessible> (owning) instead, using std::exchange to atomically swap old and new values.
bdice
requested review from
davidwendt and
harrism
and removed request for
a team
March 4, 2026 16:58
Collaborator
Author
|
This is a prerequisite for a bunch of other work targeting |
wence-
approved these changes
Mar 4, 2026
davidwendt
approved these changes
Mar 4, 2026
51 tasks done
3 tasks done
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
The set/reset functions returned
device_async_resource_ref(non-owning) to the previous resource, but the underlyingany_resourcein the map was immediately overwritten, leaving the returned ref dangling. This was UB that happened to be masked by small buffer optimization for small resource types likecuda_memory_resource.This PR returns
cuda::mr::any_resource<cuda::mr::device_accessible>(owning) instead, usingstd::exchangeto atomically swap old and new values.Checklist