Skip to content

Release compile metadata references and propagate ID lookup errors - #265

Open
sricharanreddycheruku wants to merge 2 commits into
darvid:mainfrom
sricharanreddycheruku:fix-compile-expression-lifetimes
Open

sricharanreddycheruku wants to merge 2 commits into
darvid:mainfrom
sricharanreddycheruku:fix-compile-expression-lifetimes

Conversation

@sricharanreddycheruku

@sricharanreddycheruku sricharanreddycheruku commented Oct 7, 2026 •

Copy link
Copy Markdown

Compiling multiple expressions leaks references to earlier ID and flag items because the loop overwrites each owned reference before releasing it. An ID sequence that raises during item lookup also passes NULL into integer conversion instead of propagating the exception.

Release ID and flag references after each successful iteration and at the error boundary, and check failed ID lookup before conversion. Keep the existing 34 regression and compatibility cases for metadata cleanup, sequence errors, and expression retention.

Main now contains the expression-ownership implementation from #275. This revision merges current main, preserves that implementation and its UTF-8 handling, and limits the remaining C change to metadata cleanup and ID lookup errors. The existing source branch is unchanged.

Validation on Linux with CPython 3.14.8, using a wheel built from this source with bundled Vectorscan 5.4.12:

  • python -m pytest tests/ -vvv: 66 passed, 2 skipped. The two default slow-test skips each require approximately 4 GiB and are enabled with --run-slow.
  • PYTHONMALLOC=debug python -m pytest tests/test_compile_lifetimes.py -vvv: all 34 passed.
  • Ruff 0.9.3, Black 23.12.1, clang-format 9.0.0 byte comparison, and mkdocs build --strict passed.

Against a source-built unchanged-main extension, the ID lookup regression fails with SystemError instead of the original exception, and both metadata reference-count regressions fail. Restoring the patched wheel passes all 34 cases again. git diff --check passes. Tested source is committed at 3bfcabc. Other interpreters, platforms, the slow tests, and the upstream wheel matrix have not been rerun for this revision.

@sricharanreddycheruku sricharanreddycheruku changed the title Retain expression buffers through native compilation Release compile metadata references and propagate ID lookup errors Oct 10, 2026

This branch has not been deployed

No deployments
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.

1 participant