Strange error message in log since going Xcode 4 and Lion...

Hi,

I have been getting a new error message when my apps are running, which was never present before in Snow Lion and Xcode 3.2, and now they show up almost every time it is run, and occasionally got some crashes:

malloc: reference count underflow for 0x1923500, break on auto_refcount_underflow_error to debug.

I looked into it, searched for any occurrence of auto_refcount_underflow_error in the obj-c parts of my app, but I can’t find it.

Has anyone hit this bug before? Maybe a problem with coercing somewhere? Was SL being too kind and let it go, but Lion doesn’t accept it anymore maybe? Would be useful if it were to give more details in the log…

Thanks!

Model: MBPro8,2
Browser: Safari 534.48.3
Operating System: Mac OS X (10.7)

Is there any pattern to where it happens? Calls to scripting additions, perhaps?

Nope, that’s the problem. I’m using Obj-C methods almost exclusively for this part, the rest is mostly coercions.

I can’t find the pattern, and it’s sporadic now. I changed today the method used to get the total size of folders from a terminal call to an Obj-C method, and it seems to have brought the number and frequency of errors down, but can’t be sure that’s it’s related.

Could it be when it tries to count an array perhaps?

Model: MBPro8,2
Browser: Safari 534.48.3
Operating System: Mac OS X (10.7)

It’s more likely a bug in a framework you’re calling.

So, not my fault then… :wink:

Is there any way to track down the framework? (not having high hopes)

Model: MBPro8,2
Browser: Safari 534.48.3
Operating System: Mac OS X (10.7)

Start by trying to track down where in your script it happens.

Yep, already tracking down the method from which the error is being caused. The funny thing is it doesnt seem to be the AS code that generates the error, so I’ll have to put log statements everywhere to get to the faulty part… Lots of fun in the next few hours. :confused:

Think I found the source… or at least exactly when this error is logged.

I am using your Myriad Helpers Shane, and I created an NSOpenPanel using this method:

+(NSOpenPanel *)makeOpenAt:(id)location types:(NSArray *)types files:(BOOL)files multiples:(BOOL)multiples prompt:(NSString *)prompt title:(NSString *)title;

and ask to show over my main window with this method:

-(void)showOver:(NSWindow *)window calling:(id)selOrArray URL:(BOOL)url;

and the errors are logged exactly when I select (literally click on folders) in the Open Panel. Not before the panel is created or called, and not after it is dismissed and the selected folders are returned correctly by your method.

Maybe this is just an empty warning, but it might explain why the app crashed sometimes when the panel was being dismissed…

Any ideas? I don’t see anything wrong with your code, nor in mine, I triple checked if i called your method correctly… i’m at a loss. :confused:

Model: MBPro8,2
Browser: Safari 534.48.3
Operating System: Mac OS X (10.7)

That rings a bit of a bell… what view are you using in the panel – browser?

Yep, multi-column browser. I just tried it in icon and list view, and no errors. As soon as I switch back to column view, it comes back.

Sounds like a framework error, like you said…

Model: MBPro8,2
Browser: Safari 534.48.3
Operating System: Mac OS X (10.7)

Yes, I saw the same thing in an all-Cocoa project recently. Definitely a framework problem.

Even does it when the app is idle, no panel opened, just chilling… Xcode logged 2 such errors just now. That’s strange…

Maybe I should send an bug report to Apple. My app didn’t crash in a while when the panel is open, so It might not be related, but still, it’s annoying. :slight_smile:

Thanks!

Model: MBPro8,2
Browser: Safari 534.48.3
Operating System: Mac OS X (10.7)

You definitely should.

Have you noticed that it only occurs when you are under GC. For me once I turned garbage collection off it seemed to solve all my problems. Did anyone else notice this?

i haven’t turned GC off because I was under the belief that it was much safer for ASOC apps, not mandatory, just safer.

So maybe something is off in Xcode 4 or it’s the combination of Lion & Xcode 4, who knows. I’ll send a bug report to apple, since it seems to be in the NSOpenPanel framework, at least this is as far as I was able to track the problem down to.

Browser: Safari 531.22.7
Operating System: Mac OS X (10.6)