Skip to content

Release input buffers when writing to closed streams - #381

Open
FFspiky wants to merge 1 commit into
indygreg:mainfrom
FFspiky:fix-closed-writer-buffer-release
Open

FFspiky wants to merge 1 commit into
indygreg:mainfrom
FFspiky:fix-closed-writer-buffer-release

Conversation

@FFspiky

@FFspiky FFspiky commented Nov 16, 2026

Copy link
Copy Markdown

Route the closed-stream errors in the compression and decompression writers through their existing cleanup labels, releasing the input Py_buffer before returning ValueError. A bytearray can then be resized immediately after the rejected write.

Partially addresses #296: only the two closed-writer input-buffer leaks. Other lifecycle findings in that issue are outside this patch.

Regression coverage: Empty/nonempty mutable inputs and repeated rejected writes; ValueError remains unchanged.

Validation on macOS 26.2 arm64 / CPython 3.12.14:

  • Built both backends with ZSTD_WARNINGS_AS_ERRORS=1 python setup.py build_ext --inplace.
  • C extension: 294 passed. CFFI: 268 passed, 26 skipped. Both runs enabled ZSTD_SLOW_TESTS=1 with the default Hypothesis profile (100 examples). Writer-focused tests: 37 passed on each backend. Both new C regression tests fail before the fix; the unchanged CFFI implementation passes.
  • ruff check ., mypy tests/*.py zstandard/*.py, changed-file ruff format --check, and git diff --check pass.
  • Full ruff format --check . reports only an existing setup.py indentation issue, reproduced on the untouched base.

Linux/Windows, the remaining Python version matrix, and the experimental Rust backend were not run locally.

AI disclosure: Code, tests, and this description were generated with OpenAI Codex and validated with automated local checks. This does not claim human review.

@FFspiky

FFspiky commented Nov 16, 2026

Copy link
Copy Markdown
Author

The Actions runs currently report action_required with no jobs started. Could a maintainer approve the workflows for this PR and the independent fixes in #382 and #383? Each PR records its separate C/CFFI baseline and post-fix results. Hosted CI and the remaining platform/interpreter matrix are still unverified.

This follow-up was prepared with Codex.

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