[New-bugs-announce] [issue17245] ctypes libffi needs to align the x86 stack to 16 bytes

Gregory P. Smith report at bugs.python.org
Tue Feb 19 23:11:10 CET 2013

New submission from Gregory P. Smith:

The problem: without the stack being 16-byte aligned, code generated by modern compilers like recent gcc/g++ or clang assumed that the stack is 16 byte aligned and uses SSE instructions in some circumstances that require this.  Without this fix, any ctypes call into such code will crash.

I mentioned this in the comment on issue17192 which seeks to update our ancient copy of libffi but we may want to do this independently of that.

In 2.7, we're running into the stack being misaligned in 32-bit x86 code which is something a libffi update fixes.  It is a trivial patch:


which made it into the official libffi releases in 2010 via https://github.com/atgreen/libffi/commit/3f5b1375ab1e2b8e3d593e21b27097a4a50f9b83#src/x86/sysv.S.

patch against 2.7 attached.  it should apply to any tree easily enough.

assignee: gregory.p.smith
files: fix_libffi_x86_stack_align.gps01.diff
keywords: patch
messages: 182442
nosy: benjamin.peterson, georg.brandl, gregory.p.smith, larry
priority: release blocker
severity: normal
stage: patch review
status: open
title: ctypes libffi needs to align the x86 stack to 16 bytes
type: crash
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4
Added file: http://bugs.python.org/file29124/fix_libffi_x86_stack_align.gps01.diff

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list