Skip to content

Conversation

dicej
Copy link
Collaborator

@dicej dicej commented May 29, 2025

This addresses a couple of issues:

  • We weren't freeing canonical ABI results after calling imports and then converting the results to Python values.

  • We were using the PyO3 Bound APIs incorrectly in a few places, resulting in refcounts being incremented too many times.

While debugging the latter issue, I took the opportunity to update to the latest PyO3 release, which required addressing the usual API breakage. It also required temporarily forking the repo to add a patch to disable extern "C-unwind" in pyo3_ffi on wasm32. We should be able to drop that fork once we upgrade everything to Python 3.14.

Finally, I discovered
https://pyo3.rs/v0.25.0/features.html#pyo3_disable_reference_pool which supposedly optimizes Rust<->Python transitions by disabling a feature we don't rely on anyway, so I went ahead and enabled it.

Fixes #152

dicej added 3 commits May 29, 2025 11:11
This addresses a couple of issues:

- We weren't freeing canonical ABI results after calling imports and then
  converting the results to Python values.

- We were using the PyO3 `Bound` APIs incorrectly in a few places, resulting in
  refcounts being incremented too many times.

While debugging the latter issue, I took the opportunity to update to the latest
PyO3 release, which required addressing the usual API breakage.  It also
required temporarily forking the repo to add a patch to disable `extern
"C-unwind"` in `pyo3_ffi` on `wasm32`.  We should be able to drop that fork once
we upgrade everything to Python 3.14.

Finally, I discovered
https://pyo3.rs/v0.25.0/features.html#pyo3_disable_reference_pool which
supposedly optimizes Rust<->Python transitions by disabling a feature we don't
rely on anyway, so I went ahead and enabled it.

Fixes bytecodealliance#152

Signed-off-by: Joel Dice <[email protected]>
Signed-off-by: Joel Dice <[email protected]>
@dicej dicej merged commit 72ca2f5 into bytecodealliance:main May 29, 2025
4 checks passed
@dicej dicej deleted the memory-leak-fixes branch May 29, 2025 18:00
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.

Memory not released for WASI resources

1 participant