You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support libffi implementations that cannot support invocations with 1024 arguments #91364
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2022-04-04.00:27:44.616>labels= ['ctypes', 'type-bug', 'tests', '3.11']
title='Support libffi implementations that cannot support invocations with 1024 arguments'updated_at=<Date2022-04-04.19:07:48.227>user='https://github.com/hoodmane'
If a function call is attempted with more than 1024 arguments, it will fail. The libffi emscripten port github.com/hoodmane/libffi-emscripten can only support function calls with at most 122 arguments due to limitations in Emscripten / Wasm: emscripten-core/emscripten#16653
I propose to allow the libffi port to define FFI_MAX_CLOSURE_ARGS and if this is defined then use this number instead for CTYPES_MAX_ARGCOUNT. libffi/libffi#703
The test test_callback_too_many_args should also be updated to respect the value of CTYPES_MAX_ARGCOUNT rather than hardcoding 1024 into the test.
#76478 adds #ifndef CTYPES_MAX_ARGCOUNT and exposes the constant in the _ctypes extension module, so the test case can use the constant. It allows you to override CTYPES_MAX_ARGCOUNT until libffi upstream agrees on FFI_MAX_CLOSURE_ARGS.
Ideally the library should be able to define a different macro, e.g., CTYPES_CUSTOM_MAX_ARGCOUNT. This way the libffi port can define CTYPES_CUSTOM_MAX_ARGCOUNT and it will be compatible with older Python versions without causing Warning: "CTYPES_MAX_ARGCOUNT redefined`.
Activity
hoodmane commentedon Apr 4, 2022
ctypes defines
CTYPES_MAX_ARGCOUNTto be 1024:cpython/Modules/_ctypes/ctypes.h
Line 21 in 6db2db9
If a function call is attempted with more than 1024 arguments, it will fail. The libffi emscripten port github.com/hoodmane/libffi-emscripten can only support function calls with at most 122 arguments due to limitations in Emscripten / Wasm:
emscripten-core/emscripten#16653
I propose to allow the libffi port to define FFI_MAX_CLOSURE_ARGS and if this is defined then use this number instead for
CTYPES_MAX_ARGCOUNT.libffi/libffi#703
The test
test_callback_too_many_argsshould also be updated to respect the value ofCTYPES_MAX_ARGCOUNTrather than hardcoding 1024 into the test.tiran commentedon Apr 4, 2022
New changeset d1b1c88 by Christian Heimes in branch 'main':
bpo-47208: Allow vendors to override CTYPES_MAX_ARGCOUNT (GH-32297)
d1b1c88
tiran commentedon Apr 4, 2022
#76478 adds #ifndef CTYPES_MAX_ARGCOUNT and exposes the constant in the _ctypes extension module, so the test case can use the constant. It allows you to override CTYPES_MAX_ARGCOUNT until libffi upstream agrees on FFI_MAX_CLOSURE_ARGS.
hoodmane commentedon Apr 4, 2022
Ideally the library should be able to define a different macro, e.g., CTYPES_CUSTOM_MAX_ARGCOUNT. This way the libffi port can define CTYPES_CUSTOM_MAX_ARGCOUNT and it will be compatible with older Python versions without causing Warning: "CTYPES_MAX_ARGCOUNT redefined`.
furkanonder commentedon May 5, 2023
The issue seems to be solved, I think we can close it. @tiran