Hi,

a hack used in dynamic class registration in libobjc2/runtime.c causes serious trouble for apps using this API.

This is the cause of trouble:

// Initialize the metaclass
// Set the meta-metaclass pointer to the name.  The runtime will fix this
// in objc_resolve_class().
metaClass->isa = (Class)superclass->isa->isa->name;

See the attached example app, which crashes.

I could use objc_resolve_class() in between class registrations, but that results in +load being called, which should not be happening at that point.

--
Luboš Doležel
#import <Foundation/NSObject.h>
#include <objc/runtime.h>

int main()
{
        Class a, b, c;

        a = objc_allocateClassPair([NSObject class], "A", 0);
        objc_registerClassPair(a);

        b = objc_allocateClassPair(a, "B", 0);
        objc_registerClassPair(b);

        c = objc_allocateClassPair(b, "C", 0);
        objc_registerClassPair(c);

        return 0;
}

_______________________________________________
Gnustep-dev mailing list
Gnustep-dev@gnu.org
https://lists.gnu.org/mailman/listinfo/gnustep-dev

Reply via email to