Issue 17580: ctypes: ARM hardfloat argument corruption calling functions with many float arguments (original) (raw)

Created on 2013-03-30 13:47 by bivab, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ctypes_arm.tar bivab,2013-03-30 13:47
Messages (8)
msg185557 - (view) Author: David Schneider (bivab) Date: 2013-03-30 13:47
This issue affects C functions with many float/double arguments called through ctypes on ARM using the hardfloat ABI (i.e. the standard distribution for the raspberry pi uses hard-float). Calling a C function using ctypes on ARM hard-float that takes a large number of float arguments (more than 16 floats or more than 8 doubles) corrupts the first float/double arguments passed on the stack to the called function. To check the issue run the following commands on an ARM hard-float system: make python bug.py A patch for this issue has been accepted into libffi.
msg228600 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-10-05 17:48
Could we have a reply to this from our ctypes experts, thanks.
msg261067 - (view) Author: Maciej Fijalkowski (fijall) * (Python committer) Date: 2016-03-01 20:17
Apparently you can't have an opinion from ctypes experts. Can you please commit the upstream fix that has been committed 3 years ago or just stop vendoring random, old, broken version of ctypes if you can't maintain it enough to pull fixes from upstream?
msg261087 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-03-01 22:15
To me, it doesn't make sense to maintain a downstream "fork" of libffi. I would prefer to "simply" upgrade to a more recent version of libffi in CPython. But I don't know why we have a downstream version. What was patched? Does anyone know anything about it? I understood that Linux packages configure with ./configure --with-system-libffi to reuse the system libffi.so. Who uses the downstream version? Windows? OS X?
msg261088 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-03-01 22:20
David Schneider: "A patch for this issue has been accepted into libffi." fijal: "Can you please commit the upstream fix that has been committed 3 years ago (...)" Which patch? Attached tar archive doesn't look like a patch and I see no reference to a fix. Previous libffi upgrade: --- changeset: 92061:4331fa01398e branch: 2.7 parent: 92058:928135d0fa7d user: doko@ubuntu.com date: Sun Aug 10 11:15:28 2014 +0200 files: Misc/NEWS Modules/_ctypes/libffi.diff Modules/_ctypes/libffi/.gitignore Modules/_ctypes/libffi/.travis.yml Modules/_ctypes/libffi/ChangeLog Modules/_ctypes/libffi/Change description: - Issue #22176: Update the ctypes module's libffi to v3.1. This release adds support for the Linux AArch64 and POWERPC ELF ABIv2 little endian architectures. --- This upgrade was made in august 2014, this issue was reported in march 2013. The upgrade didn't add the mentioned fix?
msg261089 - (view) Author: Maciej Fijalkowski (fijall) * (Python committer) Date: 2016-03-01 22:27
Then maybe it's fixed, I have no idea
msg261090 - (view) Author: Maciej Fijalkowski (fijall) * (Python committer) Date: 2016-03-01 22:27
The easiest way to check is to run the tests attached
msg261096 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-03-02 06:11
> Which patch? Looks like the patch can be found at https://github.com/atgreen/libffi/pull/34/ and it has been released in libffi 3.1: https://github.com/atgreen/libffi/blob/17ffc3655a531c116e9eb9cc933e50bb1e5c47f8/ChangeLog.libffi-3.1#L481 (It's hard to share a specific commit since libffi's history is not linear.) The patch also has been merged into CPython's fork in 0fef0afb9d19 (Update the ctypes module's libffi to v3.1): * https://github.com/python/cpython/blob/master/Modules/_ctypes/libffi/src/arm/ffi.c#L43 * https://github.com/python/cpython/blob/master/Modules/_ctypes/libffi/src/arm/ffi.c#L128 I don't have an ARM system to run David's reproducer (thanks for your report and for the test script, by the way!), but I think we can safely assume that this has already been fixed.
History
Date User Action Args
2022-04-11 14:57:43 admin set github: 61780
2016-03-02 06:11:22 berker.peksag set status: open -> closednosy: + berker.peksagmessages: + resolution: out of datestage: resolved
2016-03-01 22:27:44 fijall set messages: +
2016-03-01 22:27:25 fijall set messages: +
2016-03-01 22:20:27 vstinner set nosy: + doko
2016-03-01 22:20:14 vstinner set messages: +
2016-03-01 22:15:37 vstinner set messages: +
2016-03-01 20:17:14 fijall set nosy: + fijallmessages: +
2016-02-29 23:36:57 BreamoreBoy set nosy: - BreamoreBoy
2016-02-29 16:19:37 vstinner set nosy: + vstinner
2014-10-05 17:48:41 BreamoreBoy set nosy: + BreamoreBoymessages: + versions: + Python 3.5, - Python 3.2, Python 3.3
2013-06-27 19:29:43 christian.heimes set versions: + Python 3.3, Python 3.4
2013-03-30 22:52:36 pitrou set nosy: + amaury.forgeotdarc, belopolsky, meador.inge
2013-03-30 13:47:30 bivab create