Repository navigation
Conversation
GraphSolver held its device allocation in an uninitialized raw pointer, with defaulted move operations and an unconditional cudaFree in the destructor. A moved-from solver therefore freed the buffer a second time, and move assignment leaked the target's previous buffer. Hold the buffer in a std::unique_ptr whose deleter frees it on the device it was allocated on. The defaulted move operations and destructor are then correct, and the public interface is unchanged. Signed-off-by: Paul-Edouard Sarlin <psarlin@google.com>
This was referenced Dec 4, 2026
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.
Stacked on #2.
GraphSolverheld its device allocation in an uninitialized raw pointer, with defaulted move operations and an unconditionalcudaFreein the destructor. A moved-from solver therefore freed the buffer a second time, and move assignment leaked the target's previous buffer.The buffer is now held in a
std::unique_ptrwhose deleter frees it on the device it was allocated on, so the defaulted move operations and destructor are correct. The public interface is unchanged.Test plan
caspar_solver_cuda_test.cc: move-constructs and move-assigns a solver, destroys the moved-from one, and checks that the moved-to solver matches an unmoved one and that no CUDA error is left behind. The leak on move assignment is fixed by construction but not asserted.symforce_caspar_codegen_test.pyand the Caspar CUDA tests pass (nvcc, A100).