Skip to content

fix mingw build and crashing bugs for Python Windows ARM64#496

Merged
atgreen merged 2 commits intolibffi:masterfrom
paulmon:arm64_for_python_fixes
Aug 7, 2019
Merged

fix mingw build and crashing bugs for Python Windows ARM64#496
atgreen merged 2 commits intolibffi:masterfrom
paulmon:arm64_for_python_fixes

Conversation

@paulmon
Copy link
Contributor

@paulmon paulmon commented Jun 27, 2019

Fix Windows arm64 build via mingw. This is needed for Python builds.
Fix crashing bug in ffi.c. Calling dlmalloc functions on Windows results in a crash, since dlmalloc isn't used in the build.
Fix crashing bug in SEH exception unrolling in win64_armasm.S. The current code results in stack corruption because the 32 byte offsets write in the wrong location.

@paulmon
Copy link
Contributor Author

paulmon commented Jul 11, 2019

Please merge this change. The travis failure appears to be unrelated to these changes.

@paulmon
Copy link
Contributor Author

paulmon commented Jul 19, 2019

The cpython project uses mingw to build libffi-7.dll for Python: see prepare_libffi.bat. Currently the Windows ARM64 version of libffi can't be built using mingw because configure.host and Makefile.am are missing support for this.

Also, structured exception handling (SEH) tests using libffi in Python are failing because the current use of frame macros and bad pointer path with the constant #32 corrupt the stack, preventing the stack from being unrolled correctly when there is a exception within a libffi call.

The current implementation calls ffi_data_to_code_pointer which is incorrect since the Windows implementation uses the CRTs malloc and not dlmalloc.

Copy link
Member

@tromey tromey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the patch. I don't know aarch64 assembly, but I figured I could at least review parts of it. It looks pretty reasonable overall to me, just some nits to address.

@paulmon
Copy link
Contributor Author

paulmon commented Aug 2, 2019

@tromey Thanks for the review. I made the changes you requested and tested them on a Windows arm64 machine.

@atgreen atgreen merged commit c2a6859 into libffi:master Aug 7, 2019
@paulmon
Copy link
Contributor Author

paulmon commented Aug 7, 2019

Thanks!

jeremyhu added a commit to jeremyhu/libffi that referenced this pull request Apr 11, 2020
…o master

Reviewed-by: Mike Ash <[email protected]>
Reviewed-by: Matt Reda <[email protected]>

* commit '2284bfc111229c3af01722d9aab23056025a8e01': (22 commits)
  darwin arm64e: libunwind requires that the CFA match the value used to sign LR
  arm64e: Fix frame size to 40b to match earlier change in aarch64/ffi.c
  Add missing arch guards around ffi_find_closure_for_code_np
  fix mingw build and crashing bugs for Python Windows ARM64 (libffi#496)
  Clear the apt cache
  More debugging output
  Debug moxie builds in travis
  libffi: added ARM64 support for Windows (libffi#486)
  uuencode compressed log files for travis
  hppa: avoid TEXTREL in .eh_frame section (libffi#447)
  fix x86/x64 MSVC build (libffi#487)
  add support for 32-bit ARM on Windows (libffi#477)
  fix check for Linux/aarch64
  Cleanup symbol exports on darwin and add architecture preprocessor checks to assist in building fat binaries (eg: i386+x86_64 on macOS or arm+aarch64 on iOS) (libffi#450)
  Fix cfi checks for old compiler (libffi#453)
  changes for win32 on windows (libffi#468)
  aarch64: Flush code mapping in addition to data mapping (libffi#471)
  Remove -Os testing. No ABI impact, and helps trim log lengths.
  fix(configure): Correctly detect visibility("hidden") support on Darwin
  Fix Q registers parameter passing on ARM64
  ...
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.

4 participants