Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • cffi cffi
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 74
    • Issues 74
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 4
    • Merge requests 4
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • PyPy
  • cfficffi
  • Issues
  • #531

Closed
Open
Created Mar 18, 2022 by Petr Viktorin@encukou

fb_build in _cffi_backend.c hardcodes alignment to 8

ppc64le's long double is aligned to 16 bytes, making generic engine verifier tests fail on the platform with:

=================================== FAILURES ===================================
__________________________ test_longdouble_precision ___________________________
...
>           assert abs(more_precise - less_precise) > 0.1
E           assert 0.0 > 0.1
E            +  where 0.0 = abs((0.0 - 0.0))
testing/cffi0/test_verify.py:199: AssertionError

(On the machine i have access to, using 8-byte aligned long double* happens to give wrong results rather than crash outright.)

According to libffi docs, return types smaller than the system register (ffi_arg) are promoted to that size. But larger types aren't. The docs don't say how this affects alignment, put presumably the return type should be aligned to both type->alignment and ffi_arg alignment?

Arguments aren't kept aligned either. In libffi docs, I couldn't find an explicit mention of whether this is OK, but I assume it isn't.

I'm attaching a PoC patch for these issues.

The buffer in _cffi_backend's cdata_call also isn't explicitly aligned. Here I'm not sure what the best solution for python-cffi would be.

align16.patch

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking