Enforce restype
and argtypes
for send_super
#219
Labels
enhancement
New features, or improvements to existing features.
restype
and argtypes
for send_super
#219
Is your feature request related to a problem? Please describe.
rubicon.objc.runtime.send_super
doesn't check its arguments very much: it's possible to pass arguments without declaring theirargtypes
, in which case the arguments are assumed to be C-style varargs, with default types assigned byctypes
.This is problematic because the assumed default argument types don't always match what is required/intended (e. g. integer sizes). On some architectures like AArch64 (iOS and ARM Macs), fixed and variable arguments are also passed in different incompatible ways (registers vs. stack), so assuming that all arguments are varargs doesn't work in most cases.
Describe the solution you'd like
For
send_message
, we have already introduced some stricter checks (see #174), so we should implement the same checks forsend_super
as well. This is a backwards-incompatible change - any existing code that callssend_super
and doesn't already setrestype
/argtypes
will have to be updated.Describe alternatives you've considered
Instead of throwing a hard error, we could just show warnings if
restype
/argtypes
are missing/mismatched. This would allow existing code to keep working on Intel and give callers more time to update their code. ARM would be broken either way though - if we don't throw an error, most affected calls will not have their arguments passed correctly, and will probably crash.Additional context
The confusion of fixed and variable arguments has already caused some crashes in Toga on ARM Macs. This has been fixed now (beeware/toga#1406, beeware/toga#1411), but adding these checks in
send_super
would help detect similar problematic calls.The text was updated successfully, but these errors were encountered: