Skip to content

[3.14] gh-156933: Widen narrow integer results in ctypes callbacks (GH-157045) - #158296

Merged
ZeroIntensity merged 2 commits into
python:3.14from
miss-islington:backport-b6f9a50-3.14
Sep 27, 2026
Merged

ZeroIntensity merged 2 commits into
python:3.14from
miss-islington:backport-b6f9a50-3.14

Conversation

@miss-islington

@miss-islington miss-islington commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

_CallPythonObject() only wrote restype->size bytes into the closure's result buffer, leaving the unused high-order bits of the ffi_arg-sized register untouched. libffi's ffi_prep_closure_loc() documents that integral types narrower than a machine register must be widened to fill it, sign-extending signed types. On architectures that always read the full register for narrow return values (s390x), this leaves garbage in the high bits, which broke libclang callbacks used by cindex.py.
(cherry picked from commit b6f9a50)

Co-authored-by: Lazizbek Ergashev lazerg2@gmail.com

…ythonGH-157045)

_CallPythonObject() only wrote restype->size bytes into the closure's result buffer, leaving the unused high-order bits of the ffi_arg-sized register untouched. libffi's ffi_prep_closure_loc() documents that integral types narrower than a machine register must be widened to fill it, sign-extending signed types. On architectures that always read the full register for narrow return values (s390x), this leaves garbage in the high bits, which broke libclang callbacks used by cindex.py.
(cherry picked from commit b6f9a50)

Co-authored-by: Lazizbek Ergashev <lazerg2@gmail.com>
@ZeroIntensity

Copy link
Copy Markdown
Member

(I need to fix the test; see #158295 (comment)).

@ZeroIntensity
ZeroIntensity enabled auto-merge (squash) September 27, 2026 18:50
@ZeroIntensity
ZeroIntensity merged commit e4e5835 into python:3.14 Sep 27, 2026
49 checks passed
@miss-islington
miss-islington deleted the backport-b6f9a50-3.14 branch September 27, 2026 19:16
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