lacasanova / shortcutrecorder

Automatically exported from code.google.com/p/shortcutrecorder
0 stars 0 forks source link

Blows up with Garbage Collection #25

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
XCode 3.1, Leopard 10.5.5

There seems to be something going wrong with garbage collection and this 
component, getting 
the error:

malloc: *** resurrection error for object 0x108d7f0: auto_zone_write_barrier: 
NSTrackingArea._owner[48](0x105e500)[20] = SRRecorderCell[144](0x108d7f0)

malloc: *** auto malloc[1409]: error for object 0x108d7f0: pointer in garbage 
list being stored 
into reachable memory, break on auto_zone_resurrection_error to debug

I've checked and double checked the usual garbage collection issues, like 
making sure all my 
objects are attached. I'm loading a NIB, letting it go, and loading it again, 
and getting this error.

I've tried diving into the code and fiddling, but I'm not sure what is wrong.  
Anybody else using 
GC?

Original issue reported on code.google.com by idou...@gmail.com on 2 Sep 2008 at 12:36

GoogleCodeExporter commented 8 years ago
Ok, I'm starting to see the problem. When an NSWindow is finalized, it calls 
setWIndow on its views to say that 
they no longer belong to it. This ends up calling viewDidMoveToWindow on the 
view, which by default does 
nothing, but for STRecorderControl does resetTrackingRects. This in turn calls 
resetTrackingRects on the 
SRRecorderCell, which tries to set a new tracking rectangle passing itself to 
addTrackingRect. As the 
NSObject.finalize documentation says, passing yourself around to function 
during finalize is known as 
"resurrection", and is naughty. In fact, finalize really should never refer to 
any other objects at all, because 
finalization order is undefined.

Original comment by idou...@gmail.com on 2 Sep 2008 at 1:41

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
As hinted by the viewDidMoveToWindow doco, my suggested fix is the following:

// If the control is set to be resizeable in width, this will make sure that 
the tracking rects are always updated
- (void)viewDidMoveToWindow
{
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    [center removeObserver:self];
    if ([self window] != nil) {
        [center addObserver:self selector:@selector(viewFrameDidChange:) 
name:NSViewFrameDidChangeNotification object:self];
        [self resetTrackingRects];
    }
}

Adding the if () test seems to fix it.

Original comment by idou...@gmail.com on 3 Sep 2008 at 1:14

GoogleCodeExporter commented 8 years ago
being that GC is deprecated I'm marking this one as won't fix.

Original comment by rarich...@gmail.com on 19 Mar 2012 at 2:51

GoogleCodeExporter commented 8 years ago

Original comment by rarich...@gmail.com on 19 Mar 2012 at 2:52

GoogleCodeExporter commented 8 years ago
Firstly, the fix is right there, so why not put it in?

Secondly, who in the heck said GC is deprecated?

Original comment by xpusosto...@gmail.com on 19 Mar 2012 at 10:07