Created attachment 26361 [details] simple example When calling class_copyIvarList(class, NULL) with a class that has no ivars the app crashes with a segfault. Please find an example attached.
The runtime crashes at libobj.c/ivars.c line 191: count = ivar_list->ivar_count; The problem is that, when a class has no instance variables ivar_list will be NULL so this needs to be checked for.
Is anyone going to fix this? It is quite debilitating and there is no good workaround. Prior to gcc 4.6 one could include objc/deprecated/struct_objc_class.h and inspect ivar_list yourself before calling class_copyIvarList. Now that the ABI internals are private, this is no longer an option, and it's impossible to protect against.
Created attachment 34329 [details] A patch that fixes the issue and provides a suitable testcase.
Author: mrs Date: Fri Jan 9 18:12:51 2015 New Revision: 219399 URL: https://gcc.gnu.org/viewcvs?rev=219399&root=gcc&view=rev Log: Added PR libobjc/51891. Modified: trunk/gcc/testsuite/ChangeLog trunk/libobjc/ChangeLog
Fixed.