Fix crashes with Tr2PyValueBindings - #100
Open
filipppavlov wants to merge 4 commits into
Open
filipppavlov wants to merge 4 commits into
filipppavlov wants to merge 4 commits into
Conversation
- acuire Python GIL when working with Python C API - prevent tasklet switching when getting/setting attributes - prevent the binding from descruction when copying values
There was a problem hiding this comment.
Cpp-linter Review
Used clang-format v21.1.8
Click here for the full clang-format patch
diff --git a/trinity/Tr2PyValueBinding.cpp b/trinity/Tr2PyValueBinding.cpp
index 09aaa2c..ded8559 100644
--- a/trinity/Tr2PyValueBinding.cpp
+++ b/trinity/Tr2PyValueBinding.cpp
@@ -35 +35 @@ void Tr2PyValueBinding::CopyValue()
- // We need to hold a reference to ourselves while we are copying the value, because custom Python getters/setters may
+ // We need to hold a reference to ourselves while we are copying the value, because custom Python getters/setters may
Have any feedback or feature suggestions? Share it here.
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
Only a minor, non-blocking grammar nit was noted.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Fixes crashes in Tr2PyValueBinding by adding Python API and lifetime safeguards.
Changes:
- Acquires the Python GIL during lifecycle and copy operations.
- Blocks tasklet switching during attribute access.
- Keeps bindings alive while copying values.
| File | Summary |
|---|---|
trinity/Tr2PyValueBinding.cpp |
Adds GIL, tasklet-switching, and lifetime protections. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if( m_isValid ) | ||
| { | ||
| // We need to hold a reference to ourselves while we are copying the value, because custom Python getters/setters may | ||
| // end up removed this binding from the parent curve set. |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
CCPNobody
approved these changes
Sep 24, 2026
| if( m_isValid ) | ||
| { | ||
| // We need to hold a reference to ourselves while we are copying the value, because custom Python getters/setters may | ||
| // end up removed this binding from the parent curve set. |
Member
There was a problem hiding this comment.
did you mean this?
Suggested change
| // end up removed this binding from the parent curve set. | |
| // end up removing this binding from the parent curve set. |
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.

The crashes point to corruption when copying values with Tr2PyValueBinding. Add various guards to Tr2PyValueBinding methods to prevent these crashes:
https://fenriscreations.atlassian.net/browse/PLAT-12135