Strange errors

When I can't figure out what's up with some bug like the one you're talking about, I start artificially adding retains to all my objects possibly related to the bug. I make sure to comment each line where I add an artificial retain though so that I can go back and undo them later without missing any of them. It'll leak memory like mad, but it's just temporary. If after the artificial retains have been added and the bug goes away, I then know it was an error on my part, forgetting to retain something. Stress level goes down pretty quick after that. Then all you have to do is backtrack over where you added the retains and start finding out which one is the culprit, and why it needed to be retained. If the artificial retains didn't fix the bug, then the chances that it's a hair-pulling mega-bug grow quite rapidly.

AnotherJake Wrote:When I can't figure out what's up with some bug like the one you're talking about, I start artificially adding retains to all my objects possibly related to the bug. I make sure to comment each line where I add an artificial retain though so that I can go back and undo them later without missing any of them. It'll leak memory like mad, but it's just temporary. If after the artificial retains have been added and the bug goes away, I then know it was an error on my part, forgetting to retain something. Stress level goes down pretty quick after that. Then all you have to do is backtrack over where you added the retains and start finding out which one is the culprit, and why it needed to be retained. If the artificial retains didn't fix the bug, then the chances that it's a hair-pulling mega-bug grow quite rapidly.

You aren't multi-threading, by chance, are you?

I am not multithreading to my knowledge. I have crash logs that indicate one of three Exception calls: KERN_INVALID_ADDRESS, KERN_PROTECTION_FAILURE, and a null pointer 0x0000000000, 0x000000000. So...confused...so...brain...hurting...see nothing...but red...

Would the libgmalloc show up in spotlight? Is it possible that I don't HAVE libgmalloc?

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

There is a zen to bug squashing with Cocoa. It's a little different than other languages and API's, but you'll pick it up after a few more of these.

I know it seems like it might be extra hassle, but you really should try out my artificial retain count technique. Like I said, if you start adding retains and the crash goes away, stress goes down really quick. It's a brute-force approach, but when you're seeing red, brute-force is often much more fun!

BTW, some things do thread when you might not be aware of it, like Audio Queues. Usually though, system induced threads aren't where the problem is. It's usually if you are explicitly threading yourself and you aren't keeping track of when objects may be released or not. Those can be excruciatingly difficult to track down, but you'd definitely know before-hand if you were threading in that case.

Talyn Wrote:I am not multithreading to my knowledge. I have crash logs that indicate one of three Exception calls: KERN_INVALID_ADDRESS, KERN_PROTECTION_FAILURE, and a null pointer 0x0000000000, 0x000000000. So...confused...so...brain...hurting...see nothing...but red...

Would the libgmalloc show up in spotlight? Is it possible that I don't HAVE libgmalloc?

You would know if you were multithreading so no worries there at least.

The first thing to remember when hunting down elusive bugs is not to panic. I find that stepping away from my code for a couple of hours to go for a swim or a run very helpful. Over thinking at this point could get you into more trouble as you break other functions trying to repair this bug.

You are almost definitely having an issue with a retain or release there. Use the breakpoints to step through your code to get an idea of what section of code is causing the crash to help you isolate what call is causing your problems. Placing lots of extra retain statements is also very helpful and has saved my butt in the past. The first task is finding out where it is crashing then you can figure out why, don't get ahead of yourself.

libgmalloc will not show up in spotlight as spotlight ignores system files.

kodex Wrote:You would know if you were multithreading so no worries there at least.

Don't be so sure about that! Normally (99% of the time ) you would know if you were multi-threading, yes, but a week or two ago, Audio Queues bit me because I wasn't expecting to be in another thread during the buffer callback. It wasn't until a notification that I called from there started causing all sorts of bizarre crashes that I had my first clue. Luckily, I had done plenty of multi-threaded programming with Cocoa before to recognize what was happening, but I feel sorry for the poor dude who hasn't already been there.

[adding] surely I would have noticed which thread I was in when things dumped into the debugger, but since it never occurred to me that I was threaded in the first place, it would have taken me a while to notice that.

Alright, believe it or not, I think I found my malloc error: it was in fact a retention error, I was releasing a timer instead of invalidating it, which steps beyond the bounds of what a timer should do. My malloc errors are gone and I am happy once again...

Sort of. I am now running into the following problem:

After running my app for a few minutes, it will unexplicably crash with an exit code of 101. I have not been able to find ANYTHING detailing this error code. Any ideas?

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

Talyn Wrote:Alright, believe it or not, I think I found my malloc error: it was in fact a retention error, I was releasing a timer instead of invalidating it, which steps beyond the bounds of what a timer should do. My malloc errors are gone and I am happy once again...

Ha ha, sucker! Yes, that is a *very* popular one to get bit by. I know I did way back in the day too.

I have no idea what's up with the 101 code. I've never seen it. Must be some iPhone code. Is your code running on an actual iPhone?

kodex Wrote:The NDA is still in effect, the reason the thread has lived this long is that the code in question was not iPhone/Touch specific.

On that note I have no idea what a 101 exit is either, but it if it happening after several minutes of inactivity it is most likely related to a memory leak.

Nope, leaks are not an issue at this point. It is from only a few moments of active use of the application. Seems to me that the crash logs indicate some sort of null pointer issue. A delegate is being sent an unknown event and as it climbs the responder list, it is encountering the end of the list and dying. Strange...Very strange.

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

kodex Wrote:The NDA is still in effect, the reason the thread has lived this long is that the code in question was not iPhone/Touch specific.

No kidding...

And so now how are we supposed to divine an answer as to what may possibly be causing this bug if we don't know what platform we're talking about? If I know it's for iPhone then I won't talk about it (as evidenced by my numerous replies to other iPhone topics), but if it's for Mac then I can work with it.

I am actually a little offended by your comment, kodex, although I understand why you brought it up.

AnotherJake Wrote:I am actually a little offended by your comment, kodex, although I understand why you brought it up.

I definitely did not mean to offend you or anything remotely like that. The post was directed more at the thread as a whole. I don't like being the NDA police anymore then the next person but until it isn't there anymore we all have to step carefully.

My hope is that working under the assumption it is a Mac we can troubleshoot it as far as possible. I in no way meant to imply that you intended to violate the NDA in anyway.

I brought it up as a preemptive response to a possible followup thread that would prevent us for further being able to assist Talyn.

I'm sorry, I didn't mean to be twitchy about it, but we've been dealing with this perverse situation for months now, and I guess my irritation meter (as well as everyone else's) is pegged at this point. Don't feel bad about being the NDA cop. Somebody's gotta do it. You did the right thing. I wasn't thinking about the next response inadvertently shutting the thread down on Talyn. My bad.

Talyn Wrote:Nope, leaks are not an issue at this point. It is from only a few moments of active use of the application. Seems to me that the crash logs indicate some sort of null pointer issue. A delegate is being sent an unknown event and as it climbs the responder list, it is encountering the end of the list and dying. Strange...Very strange.

That does indeed sound very strange. This is probably going to sound even stranger, but have you tried rebooting your machine lately to see if that helps? Because to me, it sounds like it *might* be an OS bug of some sort, on the outside of it.