Skip to content

Conversation

@pablogsal
Copy link
Member

@pablogsal pablogsal commented Dec 27, 2025

The binary_writer_create function had several error paths where memory
allocation failures would return NULL without setting a Python exception.
This violated the C API contract and caused "returning an error without
exception set" errors when BinaryWriter initialization failed due to
memory pressure.

Added PyErr_NoMemory calls before each goto error for PyMem_Malloc and
_Py_hashtable_new_full failures. Neither of these functions set exceptions
on failure, so callers must do it explicitly. The error label only performs
cleanup and returns NULL, relying on exceptions being set beforehand.

…yWriter

The binary_writer_create function had several error paths where memory
allocation failures would return NULL without setting a Python exception.
This violated the C API contract and caused "returning an error without
exception set" errors when BinaryWriter initialization failed due to
memory pressure.

Added PyErr_NoMemory calls before each goto error for PyMem_Malloc and
_Py_hashtable_new_full failures. Neither of these functions set exceptions
on failure, so callers must do it explicitly. The error label only performs
cleanup and returns NULL, relying on exceptions being set beforehand.
@pablogsal pablogsal enabled auto-merge (squash) December 27, 2025 01:18
@pablogsal pablogsal merged commit 5436289 into python:main Dec 27, 2025
48 checks passed
@pablogsal pablogsal deleted the tachyon-memsafe branch December 27, 2025 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant