[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Segfault in -[NSObject dealloc]

From: Michael Gardner
Subject: Re: Segfault in -[NSObject dealloc]
Date: Fri, 19 May 2006 00:12:23 -0500

Ah, I thought I couldn't use the usual alloc method since I'm obtaining the Class dynamically. I didn't even realize you could do something like the following:

[objc_getClass("Foo") alloc]

since I'm used to static methods as they're implemented in C++ and Java, and forgot that class methods in Obj-C realy are just instance methods of a Class object. Got some unlearning to do, it seems...


On 5/18/06, Markus Hitter <address@hidden> wrote:

Am 18.05.2006 um 07:18 schrieb Richard Frith-Macdonald:

> On 18 May 2006, at 05:31, Michael Gardner wrote:
>> I'm allocating objects with class_createInstance(), storing them
>> on a stack (well, just a plain NSArray), and popping them off at a
>> later time. When I pop an object from the stack, it gets released
>> (as I expect), but I get a segfault from -[NSObject dealloc] that
>> I can't track down.
>> I'm pretty sure I'm not double-releasing the object since I've
>> sprinkled printf statements in my dealloc methods, and I've tried
>> looking through NSObject.m to find the culprit, but can't see
>> where the segfault is coming from (the inline functions hinder
>> debugging somewhat). What kind of things can cause segfaults in -
>> [NSObject dealloc]? Could this be a GNUstep bug?
> You can't use class_createInstance() to create instances of GNUstep
> classes (unless you build NSObject.m in the base library specially
> to permit it).
> The way to allocate OpenStep/GNUstep objects is using the
> NSAllocateObject() function.

Can I add "+[myClass alloc] would be even better"?

I'm really wondering what's the big difference between GNUsteppers
and Cocoa developers. According to the mailing lists, GNUsteppers are
regularly using low level functions (objc_...()), +load and
thisalike. On Cocoa lists, I've yet to read a single line about this
stuff; they obviously use NSObject and above and are happy with this.

Is GNUstep missing some important piece of the Obj-C cake or are
GNUsteppers simply more comfortable with the C language?


- - - - - - - - - - - - - - - - - - -
Dipl. Ing. Markus Hitter

reply via email to

[Prev in Thread] Current Thread [Next in Thread]