Re: Don't you hate it when Appkit crashes?
Re: Don't you hate it when Appkit crashes?
- Subject: Re: Don't you hate it when Appkit crashes?
- From: Graham Cox <email@hidden>
- Date: Sat, 13 Feb 2016 17:24:34 +1100
> On 13 Feb 2016, at 4:02 PM, Quincey Morris <email@hidden> wrote:
>
> I think, in the scenario I described, zombie detection won’t help. It’s not an undead object, but an undead reference.
>
Not sure I’m understanding the difference. You said:
> You could have had a reference to an object that you released, causing deallocation. That memory block is re-allocated for something in AppKit, then you accidentally release your unowned reference again. Hilarity pursues.
It’s deallocated, so AppKit uses that memory for something else. I clobber that memory using a stale reference.
With zombies, the memory isn’t deallocated, it’s just marked as belonging to a zombie. If I try and access it using a stale reference, I’d get a zombie exception. AppKit can’t obtain the memory allocated to a zombie.
So, it’s possible that I’ve committed a similar error using some arbitrary malloc’ed block, but I don’t do that very often, and I’m usually very careful about free() - as such things aren’t reference counted the memory management is both simpler and usually much more obvious when it’s wrong. Usually such allocations are wrapped in an object anyway.
One other thing I have seen that clobbers memory (and is a bugger to find) is an incorrect return type from an Obj-C method, e.g. returning a struct when a float was expected. I haven’t seen these sorts of errors for years - I think the compiler is better than it used to be at flagging mismatches in return type. I can’t quite remember how that kind of problem arose actually - something to do with return types not being part of a method’s signature, so it’s easy for a method that has the same signature as another (but with a different return type) to get compiled as the wrong type. Probably grasping at straws there…
> even if you don’t think Swift is a superior language
Would never say that. If I could stop fighting fires and having to make a living from the code I have, I might find the time to learn it.
—Graham
_______________________________________________
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