Missing GIL release and mutable state race in HeightErrorFunction#1287
Open
cstollmeta wants to merge 1 commit intomainfrom
Open
Missing GIL release and mutable state race in HeightErrorFunction#1287cstollmeta wants to merge 1 commit intomainfrom
cstollmeta wants to merge 1 commit intomainfrom
Conversation
Summary: This diff fixes two thread-safety bugs: 1. Solver.solve() in pymomentum did not release the Python GIL during CPU-intensive Gauss-Newton optimization, blocking all Python threads. Added py::gil_scoped_release matching the pattern already used in solve_sequence(). 2. HeightErrorFunctionT stored mutable SkeletonStateT and MeshStateT as class members. When the same error function instance was shared across frames via addErrorFunction(kAllFrames, ...), the sequence solver's parallel frame processing would concurrently mutate these members, causing a data race. Fixed by converting mutable members to local variables in each method and passing them as parameters to helper functions. This makes HeightErrorFunctionT stateless and safe for shared use across parallel frames. Differential Revision: D100865760
Contributor
|
@cstollmeta has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100865760. |
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.
Summary:
This diff fixes two thread-safety bugs:
Solver.solve() in pymomentum did not release the Python GIL during CPU-intensive Gauss-Newton optimization, blocking all Python threads. Added py::gil_scoped_release matching the pattern already used in solve_sequence().
HeightErrorFunctionT stored mutable SkeletonStateT and MeshStateT as class members. When the same error function instance was shared across frames via addErrorFunction(kAllFrames, ...), the sequence solver's parallel frame processing would concurrently mutate these members, causing a data race. Fixed by converting mutable members to local variables in each method and passing them as parameters to helper functions. This makes HeightErrorFunctionT stateless and safe for shared use across parallel frames.
Differential Revision: D100865760