Re: Release mode bindings crash and release pools
Re: Release mode bindings crash and release pools
- Subject: Re: Release mode bindings crash and release pools
- From: Jonathan Mitchell <email@hidden>
- Date: Thu, 15 Jun 2017 20:55:39 +0100
> On 15 Jun 2017, at 20:03, Quincey Morris
> <email@hidden> wrote:
>
> On Jun 15, 2017, at 04:46 , Jonathan Mitchell <email@hidden> wrote:
>>
>> The crash occurs when the pool gets drained.
>
>> Wrapping my -bind: calls in a release pool solves the issue too.
>
> The information you’ve provided doesn’t make a lot of sense by itself. If
> draining an autorelease pool is leading to a crash, then putting the affected
> objects in a different autorelease pool and draining *that* should also crash.
Thanks for the reply.
Sorry that wasn’t clear.
The crash occurs when the default application created thread pool gets drained.
It doesn’t crash if I supply a local thread pool that just wraps the -bind:.
Its the timing of when the relevant pool gets drained that seems to be
important.
I don’t know what effect the release optimisation is having to cause this issue
to appear.
>
> Have you tried turning on Zombies to find out which incorrect reference is
> being followed?
>
Yes.
The NSViewController is calling its internal implementation that removes itself
from the responder chain - _removeFromResponderChain
This method calls [NSWindow nextResponder] and the crash occurs there as the
NSWindow is a zombie.
The nextResponder property uses assign memory semantics so it is prone to this
sort of thing.
In my NSViewController subclass I already set self.nextResponder to nil in
dealloc.
But I don’t set self.view.nextResponder to nil in dealloc and this causes the
crash in loc_307c88: as view.nextResponder == deallocated NSWindow instance.
But setting self.view.nextResponder to nil in dealloc would affect responder
chain patching for all view controllers and may have unwanted results.
So I will need to think about that.
void -[NSViewController _removeFromResponderChain](void * self, void * _cmd) {
r14 = self;
if ([self _viewControllerSupports10_10Features] == 0x0) goto .l1;
loc_307c3c:
r12 = r14->view;
rax = [r12 nextResponder];
if (rax == 0x0) goto .l1;
loc_307c63:
rbx = rax;
if (rbx == r14) goto loc_307c88;
loc_307c6b:
rax = [rbx nextResponder];
r12 = rbx;
if (rax != 0x0) goto loc_307c63;
.l1:
return;
loc_307c88:
[r12 setNextResponder:[r14 nextResponder]];
return;
}
J
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden