Bug 39817

Summary: objc_msg_sendv crashes on AMD64
Product: gcc Reporter: js-gcc
Component: libobjcAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: blocker CC: danglin, gcc-bugs, ghazi, hjl.tools, janis, js-gcc, pinskia
Priority: P3    
Version: 4.3.2   
Target Milestone: ---   
Host: x86_64-linux-gnu Target: x86_64-linux-gnu
Build: x86_64-linux-gnu Known to work:
Known to fail: Last reconfirmed:

Description js-gcc 2009-04-19 15:40:20 UTC
On AMD64, using objc_msg_sendv leads to a segfault. This is because libobjc uses __builtin_return in objc_msg_sendv, which is broken on AMD64. I'm not sure whether I should create another bug that it's broken on AMD64 or if I should just report it as a bug in libobjc.

The workaround would be to use libffi in objc_msg_sendv.

This bug renders libobjc pretty useless on AMD64, because forwarding is used a lot in objc and each time you forward something, it just crashes. This is the reason why I chose blocker as severity, it makes libobjc completely useless on AMD64. And I'm pretty sure this affects other architectures as well.

The backtrace is:
#0  0x0000000000600c30 in _OBJC_SELECTOR_TABLE ()
#1  0x0000000000000000 in ?? ()

If you change objc_msg_sendv to not use __builtin_return but instead return for example NULL, it works (though of course the return value is wrong).

I really recommend getting this fixed for the next 4.3 release. Objc support is unusable as it is on AMD64 atm.

I'm confused that none of the GNustep guys reported this before, but I remember that they're using libffi somewhere, so most likely they'll use it here as well.
Comment 1 Andrew Pinski 2009-04-19 15:52:19 UTC
>I really recommend getting this fixed for the next 4.3 release.
Considering this has always been broken since the first release of libobjc which supported a target that passed via registers (aka have always been broken since the first release :) ), this is not going to be fixed until at least 4.5 now since 4.3 and 4.4 are both in regression only mode (aka release mode).

*** This bug has been marked as a duplicate of 36610 ***