Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ctypes libffi needs to align the x86 stack to 16 bytes #61447

Closed
gpshead opened this issue Feb 19, 2013 · 3 comments
Closed

ctypes libffi needs to align the x86 stack to 16 bytes #61447

gpshead opened this issue Feb 19, 2013 · 3 comments
Assignees
Labels
release-blocker type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@gpshead
Copy link
Member

gpshead commented Feb 19, 2013

BPO 17245
Nosy @birkenfeld, @gpshead, @larryhastings, @benjaminp
Files
  • fix_libffi_x86_stack_align.gps01.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/gpshead'
    closed_at = <Date 2013-03-20.00:17:19.585>
    created_at = <Date 2013-02-19.22:11:10.508>
    labels = ['type-crash', 'release-blocker']
    title = 'ctypes libffi needs to align the x86 stack to 16 bytes'
    updated_at = <Date 2013-03-20.00:17:19.584>
    user = 'https://github.com/gpshead'

    bugs.python.org fields:

    activity = <Date 2013-03-20.00:17:19.584>
    actor = 'gregory.p.smith'
    assignee = 'gregory.p.smith'
    closed = True
    closed_date = <Date 2013-03-20.00:17:19.585>
    closer = 'gregory.p.smith'
    components = []
    creation = <Date 2013-02-19.22:11:10.508>
    creator = 'gregory.p.smith'
    dependencies = []
    files = ['29124']
    hgrepos = []
    issue_num = 17245
    keywords = ['patch']
    message_count = 3.0
    messages = ['182442', '184202', '184713']
    nosy_count = 5.0
    nosy_names = ['georg.brandl', 'gregory.p.smith', 'larry', 'benjamin.peterson', 'fijall']
    pr_nums = []
    priority = 'release blocker'
    resolution = 'fixed'
    stage = 'patch review'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue17245'
    versions = ['Python 2.7', 'Python 3.2', 'Python 3.3', 'Python 3.4']

    @gpshead
    Copy link
    Member Author

    gpshead commented Feb 19, 2013

    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 bpo-17192 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:

    http://patchwork.ozlabs.org/patch/58128/

    which made it into the official libffi releases in 2010 via atgreen/libffi@3f5b137#src/x86/sysv.S.

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

    @gpshead gpshead self-assigned this Feb 19, 2013
    @gpshead gpshead added the type-crash A hard crash of the interpreter, possibly with a core dump label Feb 19, 2013
    @fijall
    Copy link
    Mannequin

    fijall mannequin commented Mar 14, 2013

    This patch is not in the whatever version ubuntu supplies. Btw, this is code duplication, since there is already darwin alignment, see 17423

    @gpshead
    Copy link
    Member Author

    gpshead commented Mar 20, 2013

    I've updated libffi to v3.0.13 which contains the fixes for this in 2.7, 3.2, 3.3 and 3.4.

    if someone wants to apply a surgical patch to fix this problem, the one mentioned above is good as well as:

    atgreen/libffi@ee18766

    I'm not actually positive that _both_ of those two small libffi patches are needed but they both fix the same thing and it doesn't hurt to have both and both are in the v3.0.13 libffi release.

    @gpshead gpshead closed this as completed Mar 20, 2013
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    release-blocker type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant