-
Notifications
You must be signed in to change notification settings - Fork 3.5k
-rac_signalForSelector: may fail for struct returns #783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The low level ABI expands on what "some struct return types" means. The details might differ between architecture but the gist of it is "structs (or unions that can be structs) bigger than 2 registers unless it's a struct with two floating point fields". One could get the size of the return type using
I thought this had something to do with the lifting, but since it's only for |
What about exposing the underlying crack and letting the users call a I'm also fine with just documenting that structs aren't supported. |
I'd rather hide the runtime ugliness if we can, since it's a really low-level thing — this is one reason why However, I also don't really want to jump through those special casing hoops. We should probably start with some unit tests, to see whether this is a real problem or just theoretical, because it's really unclear to me why the runtime would behave differently upon finding an |
I'll take it as an excuse to procrastinate writing my résumé. |
I found the part in clang where the logic for figuring out whether a function is supposed to return the value through registers or memory: Assuming I'm still of the opinion we're better off documenting |
I was wondering the same. Looks like objc has an private intermediary version, The docs for
|
Sources say
This might be referring to In fact you if look at the source // Translate forwarding function to C-callable external version
if (imp == _objc_msgForward_internal) {
return _objc_msgForward;
} |
Yep, there be dead ends. My comment was to answer how the runtime handles the two, I had no actual good suggestions. Call-ability aside, A really bad idea is we could make our own I agree, we document it unsupported, and if the need comes up, deal with it then. |
I've found out |
Nice find. I just dug in to see where it was getting the info from, but not surprisingly it's another dead end. |
In 732726b, I tried to hijack So yeah, this seems like a fairly lost cause, unless we want to add libffi as a dependency and use that to determine struct returns. I'm 👍 on just documenting that they're unsupported. |
:slow: 👏 Absolutely amazing! I thought about how could we use |
Sorry I'm late to this; I went through exactly this problem for another project, and the only public way to determine if a method is special struct return is using I filed a Radar for this; it should really be public API, and |
Closing, resolved by #787. |
As pointed out on Twitter by @numist and @steipete, there's an
_objc_msgForward_stret
which we're not currently using. This could cause-rac_signalForSelector:
to fail when targeting a method that returns a struct.Since this is only an issue for existent methods, it's easy enough to retrieve their Objective-C type encoding. However, we can't simply check for a struct type, since a union may or may not contain a struct, and the
<objc/message.h>
documentation says that_stret
variants should only be used "for some struct return types" (emphasis mine).Maybe we should just state that struct returns are unsupported here.
The text was updated successfully, but these errors were encountered: