Skip to content

Fix crashes with Tr2PyValueBindings - #100

Open
filipppavlov wants to merge 4 commits into
mainfrom
pyvaluebinding-guards
Open

filipppavlov wants to merge 4 commits into
mainfrom
pyvaluebinding-guards

Conversation

@filipppavlov

Copy link
Copy Markdown
Member

The crashes point to corruption when copying values with Tr2PyValueBinding. Add various guards to Tr2PyValueBinding methods to prevent these crashes:

  • acquire Python GIL when working with Python C API
  • prevent tasklet switching when getting/setting attributes
  • prevent the binding from destruction when copying values

https://fenriscreations.atlassian.net/browse/PLAT-12135

- acuire Python GIL when working with Python C API
- prevent tasklet switching when getting/setting attributes
- prevent the binding from descruction when copying values
Copilot AI lite review requested due to automatic review settings September 24, 2026 10:34

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread trinity/Tr2PyValueBinding.cpp Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

Only a minor, non-blocking grammar nit was noted.

Review effort: Lite
Findings: 1 Low severity

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.

Comment thread trinity/Tr2PyValueBinding.cpp Outdated
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>
@github-actions
github-actions Bot dismissed their stale review September 24, 2026 10:42

outdated suggestion

Comment thread trinity/Tr2PyValueBinding.cpp Outdated
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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants