Malloc Error?

Hi all,
I’m getting the following error messages every once in a while:

malloc: *** auto malloc[29019]: error for object 0x4012478c0: resurrection of thread local garbage belonging to another thread
malloc: resurrection error for object 0x4012478c0 while assigning {conservative-block}224[16] = {uncollectable-memory}(0x4012478c0)
garbage pointer stored into reachable memory, break on auto_zone_resurrection_error to debug

I tried some googling and the best that I can figure out is that this is some sort of memory allocation issue, which is something that I thought we didn’t have to worry about with ASOC. I’m not sure how to translate what I found to the world of ASOC. It seems to only happen if multiple instances of an object are created, which seems to jive with this being a memory issue (but it’s not consistent).

By the way, about all the OBJ-C I know is what I’ve had to noodle through for ASOC programming. Any hints on where to look for a solution would be greatly appreciated.

Is the error crashing your program? I’ve gotten this in several apps that I’ve written, and in some it crashes the app and in others it doesn’t. In one recent app, I got this error if I tried to have the app process a folder that was very large but not with smaller folders. In any case, I think this is a bug in apple’s code not yours, so there’s nothing that you can do about it other than filing a bug report.

Ric

Unfortunately, it is crashing the program. The good news is that it’s not happening all the time, it just seems to happen when the application is “worked hard”. Still, users should be able to expect an error free experience. It seems like there should be something that can be done. Is it just a random error? I’m still trying to pin down what is triggering it.

There’s not a lot you can do, as Ric says. If it’s any consolation, you mightn’t have much more chance tracking it down in Objective-C. You can try going to the debugger and typing po 0x4012478c0 (or whatever the address is) to try to find out what the object involved is.

No luck tracking down the problem. With some patience, I can trigger an error, it’ll be consistent, but then once I recompile, no more error, and some other repeated action will trigger a different repeatable error until the next recompile. Frustrating. I’m wondering, is this an ASOC issue or would I run into the same errors if I was programming in OBJ-C?

It’s most likely an error in the frameworks. All you can do is try to track down what triggers it, and logs a bug.

Tracking sown where it happens might be easier if you were using Objective-C, but if it’s in a framework you still wouldn’t be able to do anything about it.

That’s bad news. That means you have to dig deeper to find the problem.

The problem is probably that two threads have a lock on the same memory (you need 1 lock in threads). Normally you can create memory in one thread and free it in the other. When both have a lock on it and one of the threads garbage collector want to free memory you’ll get these errors.

The only advise, because we only get so few information, is that you have to watch the memory address where the error occurs. If the address is consistent you now it’s a static problem and you can check it with a memory browser. I use bit slicer a lot and when the memory set (it updates instantly) you have to look if it’s protected or not. If so than you have a double lock on the threads. At least you know the problem and you have to look into threads only (like modal windows).

Still no luck in narrowing down the problem. It has proven not repeatable enough pin down. I gave bit slicer a try, but had a hard time interpreting the results. I think I’ll have to take a close look at how use it properly.

I did get a new message today. Unfortunately, I didn’t copy it down and now I can’t trigger it again. It did however say something about “over retaining” an object. And it specifically mentioned NSPredicate, which I don’t have too many of so I could track down the relevant code. Here’s a snippet of the handler:

	on tableSelectionChanged_(sender)
		tell current application's NSArray to set tempArray to arrayWithArray_(myList)
		tell current application's NSPredicate to set aPredicate to predicateWithFormat_("theSelection = 1")
		set selectedList to (tempArray's filteredArrayUsingPredicate_(aPredicate)) as list
		tell current application's NSPredicate to set aPredicate to predicateWithFormat_("theSelection = 0")
		set notSelectedList to (tempArray's filteredArrayUsingPredicate_(aPredicate)) as list
		tell current application's NSPredicate to set aPredicate to predicateWithFormat_("selectionType = 'Audio'")
		set audCount to tempArray's filteredArrayUsingPredicate_(aPredicate)'s |count|() as integer
		-- more stuff like the above
	end tableSelectionChanged_

From my research on objective-c, the error message makes it sound like I should tell aPredicate to release, but I didn’t think that was possible with garbage collection??? Is there a problem when I redefine aPredicate multiple times. Does that send it too many retain messages?

Also, on a side note, I’m still using Xcode 3.2.6 on Lion, and I just noticed that Apple does not support this version of Xcode for Lion. Could that be source of the problems I’m seeing?

Console.app is your friend; you can search logs.

It’s not.

No. It’s just a problem in the frameworks somewhere. If you can find the error message, log a bug.

I doubt it, but it’s possible. Much and all as Xcode 3 was better at handling AS, you’re going to have to bite the bullet sooner or later. And using an external editor can actually make the AS side of things better than Xcode 3.