Skip to content

Conversation

@robsdedude
Copy link
Member

The extensions implementation of packstream Structure could leak memory when being part of a reference cycle. In reality this doesn't matter because the driver never constructs cyclic Structures. Every packstream value is a tree in terms of references (both directions: packing and unpacking).

This change is meant to harden the extensions against introducing effective memory leaks in the driver should the driver's usage of Structure change in the future.

See also https://pyo3.rs/v0.22.0/class/protocols#garbage-collector-integration

Backport of:

The extensions implementation of packstream `Structure` could leak memory when
being part of a reference cycle. In reality this doesn't matter because the
driver never constructs cyclic `Structure`s. Every packstream value is a tree in
terms of references (both directions: packing and unpacking).

This change is meant to harden the extensions against introducing effective
memory leaks in the driver should the driver's usage of `Structure` change in
the future.

See also https://pyo3.rs/v0.22.0/class/protocols#garbage-collector-integration
Copy link

@StephenCathcart StephenCathcart left a comment

Choose a reason for hiding this comment

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

👍

@robsdedude robsdedude merged commit 85379e0 into 5.0 Jul 29, 2025
8 checks passed
@robsdedude robsdedude deleted the harden-against-memory-leak-5.28 branch July 29, 2025 13:56
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