New submission from Nicolas Dessart <nicolas.dess...@gmail.com>:

On armhf and for variadic functions (and contrary to non-variadic functions), 
the VFP co-processor registers are not used for float argument parameter 
passing. This specificity is apparently completely disregarded by ctypes which 
always uses `ffi_prep_cif` to prepare the parameter passing of a function while 
it should most probably use `ffi_prep_cif_var` for variadic functions.

As such variadic function call with float arguments through ctypes
is currently broken on armhf targets.

I think that ctypes API should be updated to let the user specify if a function 
is variadic.

I've attached a patch to the ctypes unit tests that I'm using to reproduce this 
bug.


pi@raspberrypi:~/code/cpython $ ./python -m test test_ctypes    
0:00:00 load avg: 0.00 Run tests sequentially
0:00:00 load avg: 0.00 [1/1] test_ctypes
_testfunc_d_bhilfd_var got 2 3 4 -1242230680 -0.000000 -0.000000
test test_ctypes failed -- Traceback (most recent call last):
  File "/home/pi/code/cpython/Lib/ctypes/test/test_functions.py", line 146, in 
test_doubleresult_var
    self.assertEqual(result, 21)
AssertionError: -7.086855952261741e-44 != 21

test_ctypes failed

== Tests result: FAILURE ==

1 test failed:
    test_ctypes

Total duration: 3.8 sec
Tests result: FAILURE

----------
components: ctypes
files: ctypes_variadic_function_tests.diff
keywords: patch
messages: 361992
nosy: Nicolas Dessart
priority: normal
severity: normal
status: open
title: variadic function call broken on armhf when passing a float argument
versions: Python 3.9
Added file: 
https://bugs.python.org/file48895/ctypes_variadic_function_tests.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39632>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to