[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: NSZombie
From: |
Richard Frith-Macdonald |
Subject: |
Re: NSZombie |
Date: |
Sat, 26 Jun 2010 15:24:00 +0100 |
On 26 Jun 2010, at 13:15, Sergey Golovin wrote:
> Hi!
>
> Perhaps I passed some changes. I have a trouble with the following program:
>
> ------------------------------------------------------------------------------------------------------------------------
> #import <Foundation/Foundation.h>
>
> int main(int argc, char **argv, char **env) {
> NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
> NSObject *anObject = AUTORELEASE([NSObject new]);
>
> RELEASE(anObject);
> RELEASE(anObject);
> [pool release];
>
> return 0;
> }
> ------------------------------------------------------------------------------------------------------------------------
>
> I get the segmentation fault with NSZombieEnabled=NO as supposed.
> But I get nothing with NSZombieEnabled=YES.
>
> Is it a valid behavior?
It's wrong ... you should get an error message.
This appears to be a bug/feature of the objective-c runtime.
There is a category 'Object(NSObjectCompat)', which adds a dummy implementation
for -release to the 'Object' class.
The 'NSZombie' class does NOT inherit from 'Object'.
Yet it appears that the implementation of 'release' from the category is being
used.
A proper fix for this would probably be to cure the issue in the objc runtime.
A workaround is simply remove the category which defines -release for Object
... this seems to work, and I make the change in subversion trunk.
- NSZombie, Sergey Golovin, 2010/06/26
- Re: NSZombie,
Richard Frith-Macdonald <=