Strange errors

Member
Posts: 215
Joined: 2008.06
Post: #1
Any idea what might cause a "double free" error? And does anyone know if a CALayer has a fireDate method or not? I can't find it in the documentation.

Mac users swear by their computers, PC users swear at their computers. ~Unknown

iSayz
Quote this message in a reply
Moderator
Posts: 613
Joined: 2004.09
Post: #2
double free is definitely a memory issue try stepping through your code with GuardMalloc.
Quote this message in a reply
Member
Posts: 215
Joined: 2008.06
Post: #3
kodex Wrote:double free is definitely a memory issue try stepping through your code with GuardMalloc.

Hmm, well, call me a newb, but I don't know what GuardMalloc is...?

Mac users swear by their computers, PC users swear at their computers. ~Unknown

iSayz
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
Double Free is when you free something that's already been freed, as the name suggests Wink

Xcode has a "Run With -> Guard Malloc" command which may turn out to be handy Rasp
Quote this message in a reply
Moderator
Posts: 3,573
Joined: 2003.06
Post: #5
Talyn Wrote:And does anyone know if a CALayer has a fireDate method or not? I can't find it in the documentation.

fireDate is only available in NSTimer, and CALayer does not inherit from NSTimer, so no. You can hold down the option key and double-click on any method in your code to get a quick search for it in the docs BTW.
Quote this message in a reply
Member
Posts: 215
Joined: 2008.06
Post: #6
OneSadCookie Wrote:Double Free is when you free something that's already been freed, as the name suggests Wink

Xcode has a "Run With -> Guard Malloc" command which may turn out to be handy Rasp

Well, that's kind of strange, because when I release something that has already been released to a 0 retain count, it gives me a EXC_BAD_ACCESS error, not a malloc error. Ah! What does Guard Malloc do, out of curiosity?

Oh yeah, and another thing Rasp : Anyone know what an exit code 101 is? Happens at random and I have found absolutely nothing about it in any docs, mans, or online.

Mac users swear by their computers, PC users swear at their computers. ~Unknown

iSayz
Quote this message in a reply
Member
Posts: 215
Joined: 2008.06
Post: #7
Yeah, that's why I'm confused. I keep having my app crash because it says "unrecognized selector sent to instance... [CALayer fireDate:] NSException." Also, the Research Assistant is AMAZING. Open that by Ctrl-Shift-?, it has quick references to what you're typing, links to the docs, and even sample code references. Best feature in XCode yet.

Mac users swear by their computers, PC users swear at their computers. ~Unknown

iSayz
Quote this message in a reply
Moderator
Posts: 3,573
Joined: 2003.06
Post: #8
Don't call methods that don't exist or it will throw an exception! You need to pay close attention to your warnings, and perhaps even treat warnings as errors so that it forces you to deal with them before you get to play.

I think Research Assistant is neat, but is generally not very useful to me and clutters my workspace, so I prefer to option-double-click to quickly jump to documentation when I need it from time to time. command-double-click is equally (if not more) useful because it sends you to the declaration in the appropriate header.
Quote this message in a reply
Member
Posts: 215
Joined: 2008.06
Post: #9
AnotherJake Wrote:Don't call methods that don't exist or it will throw an exception! You need to pay close attention to your warnings, and perhaps even treat warnings as errors so that it forces you to deal with them before you get to play.

I think Research Assistant is neat, but is generally not very useful to me and clutters my workspace, so I prefer to option-double-click to quickly jump to documentation when I need it from time to time. command-double-click is equally (if not more) useful because it sends you to the declaration in the appropriate header.

It's not me! We have not code that calls that method in the CALayer. I have no idea why it's being called. The only thing I can think of is there is some side effect to all the animations we have, but if that is the case, it's Apple's fault. I don't even know where to start debugging this one. I'm probably going to have to follow the stack for the next couple of hours (or days...) to watch where this unrecognized method gets called Cry

Mac users swear by their computers, PC users swear at their computers. ~Unknown

iSayz
Quote this message in a reply
Moderator
Posts: 3,573
Joined: 2003.06
Post: #10
Hmm... Well if you aren't calling the non-existent method then perhaps it is the OS that is calling it, and it is calling it an unrecognized selector because it is calling it on an object which has already been released? Impossible to say for sure what is happening on the system's side of the fence, however:

Neglecting to retain an object or inadvertently releasing one is the root of probably 75% of all the mystery bugs and memory issues I've ever had with Cocoa. One quick way to help confirm this is to add a retain to your suspected object.
Quote this message in a reply
Apprentice
Posts: 6
Joined: 2006.10
Post: #11
You could try enabling zombies (add NSZombieEnabled with YES to your environment variables), set a breakpoint on objc_exception_throw, and then run in the debugger. That should stop you when you try to message the dead object.
Quote this message in a reply
Member
Posts: 215
Joined: 2008.06
Post: #12
Ok, Guard Malloc brought up a fatal error with this error code:

dyld: could not load inserted library: /usr/lib/libgmalloc.dylib

This suggests that the lingmalloc library is not linking properly (to the best of my guesses). Any ideas on how to solve this issue?

Mac users swear by their computers, PC users swear at their computers. ~Unknown

iSayz
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #13
Are you doing iPhone dev? Who knows if guard malloc works there. NSZombieEnabled probably does, if you can figure out how to use it.

Your two bugs could well be related, the double free and the message being sent to an unexpected object.
Quote this message in a reply
Moderator
Posts: 613
Joined: 2004.09
Post: #14
That is the Guard Malloc library, see; http://developer.apple.com/documentation...loc.3.html
Quote this message in a reply
Member
Posts: 215
Joined: 2008.06
Post: #15
OneSadCookie Wrote:Are you doing iPhone dev? Who knows if guard malloc works there. NSZombieEnabled probably does, if you can figure out how to use it.

Your two bugs could well be related, the double free and the message being sent to an unexpected object.

That's what we figured. But, of course, the malloc error being so damned elusive, it's going to be hard to tell until it's fixed.

Mac users swear by their computers, PC users swear at their computers. ~Unknown

iSayz
Quote this message in a reply
Post Reply