Given this small Objective-C program:
@protocol b <a>
int main(int argc, char **argv)
if ([@protocol(b) descriptionForInstanceMethod: @selector(aMethod)] != NULL)
-> Segmentation fault
The segfault occurs in the libobjc when the Protocol tries to check it's
parents. The 'protocols'-Array contains a pointer which does _not_ point to the
parent protocol! That's why the prog crashes.
When inserting the line
if ([@protocol(a) descriptionForInstanceMethod: @selector(aMethod)] != NULL)
as first line in the main-method all is good. The protocol 'a' (the parent) is
initialized and 'b' finds it's parent and the line that caused the crash before
is running without problems.
This is extremly critical to me and maybe a patch could be posted here so I can
patch my gcc?
P.S.: I set the component to 'libobjc' because I think that it's containing the
objc-runtime. Is this correct?
Confirmed, the problem is in the front-end, not marking the protocol a for being initialization.
Note this only effects the GNU runtime.
L_OBJC_PROTOCOL_a should be added to L_OBJC_STATIC_INSTANCES.
The bug is in objc_build_protocol_expr, I will figure out how to fix this.
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-10/msg02773.html>. I don't know if it applies
to the 3.4 branch at all. And don't know if this is a regression (I will check tomorrow).
Will this get fixed in the 3.4 branch?
Most likely not as I think it was broke with 2.95.3 also (but I have to check). I also need to update the
patch for the comments.
*** Bug 23214 has been marked as a duplicate of this bug. ***
Is there any hope that this bug will be fixed in a GCC release?
It really sucks to have to patch every new installed release.
What can I do to make the fix do it's way into a GCC release?
I will try to update the patch tomorrow and submit it again for 4.1.
I have no time to update the patch right now, I might try to get to next week but I am going to unassign it for now.
Date: Sun Oct 17 10:11:23 2010
New Revision: 165579
2010-10-17 Nicola Pero <email@example.com>
* objc.dg/pr18255.m: New.
I fixed this in trunk (will be 4.6.0). Testcase committed to the testsuite.
Thank you very much!