Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
Using ctypes with variadic functions on ARM64 macOS machines seems to improperly pass the arguments, leading to truncation.
Minimal repro:
>>>importctypes>>>fromctypesimportutil>>>libc=ctypes.CDLL(util.find_library("c"))>>>libc.printf(b"hello %d world\n",128_000_000)hello0world14
This happens regardless of casting it to actypes.c_int explicitly or not.
>>>libc.printf(b"hello %ld world\n",ctypes.c_int(1))hello0world14
On my regular machine (in this case an x64 Windows machine) it works as expected:
>>>importctypes>>>libc=ctypes.cdll.msvcrt>>>libc.printf(b"hello %d world\n",128_000_000)hello128000000world22
Your environment
I do not personally have a macOS machine, but I got a few others who did have a machine test for me. Their versions were as follows:
Machine 1:Python 3.10.1, macOS 12.3.1 (21E258)
Machine 2:
Python 3.9.13 (v3.9.13:6de2ca5339, May 17 2022, 11:37:23) [Clang 13.0.0 (clang-1300.0.29.30)] on darwinmacOS-12.2.1-arm64-arm-64bitMachine 3:
~ % python3 --versionPython 3.9.10~ % sw_versProductName: macOSProductVersion: 12.3.1BuildVersion: 21E258- CPython versions tested on: 3.9, 3.10
- Operating system and architecture: ARM64 Apple Silicon macOS