Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread Display Modes
Old Jul 15, 2009, 08:03 AM   #1
macrumors member
Join Date: Jan 2008
Location: Bel Air, MD USA
Malloc headache -- how to debug?

Hi Folks,

In the scanning app I'm working on, I'm getting the following error when I send the signal to cancel the scan operation:

MyScan(25156,0xa046b720) malloc: *** free() called with 0x1add80 with refcount 0
MyScan(25156,0xa046b720) malloc: *** auto malloc[25156]: agc error for object 0x1add80: Deallocating a non-block

I'm not calling malloc() or free() anywhere so I'm guessing this must be happening in one of the dylibs I link to. How can I discover which one?

Some background:
The app uses the SANE API for image acquisition, which is written in C so I have to mix in C calls and data types to get it to work. My "Scan" object runs in a separate thread using NSOperation and the "sane_cancel()" command is called from the main thread. The command is trapped like this:

while (status == SANE_STATUS_GOOD) {
	status = sane_read (saneHandle,lineBuffer,maxlength,&bytesReturned);
	//*** Exit loop if a sane_canel() order is issued
	if (status == SANE_STATUS_CANCELLED) {
	[dataBuffer appendBytes: lineBuffer length: bytesReturned];
Thanks in advance,

-- Mark

Last edited by mpemburn; Jul 15, 2009 at 08:30 AM.
mpemburn is offline   0 Reply With Quote
Old Jul 19, 2009, 08:14 AM   #2
macrumors 6502
Join Date: Apr 2008
We'll probably need some more context here. You could do some "old-fashined printf-logging" in the code _after_ the while loop you're showing, to find out where exactly things are going wrong. It doesn't seem to be that the sane_cancel() call invalidates handles or anything, but I must admit I only quickly browsed through the SANE documentation. It does mention that the SANE API does not require any other operations to be re-entrant, so a frontend must not call any other operation until the cancelled operation has returned. Perhaps in addition to calling sane_cancel() from the main thread you're also doing something else?
Sander is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
iPhone: updating to 6.1.3 from 4.3.3 headache JollyJ Jailbreaks and iOS Hacks 5 Nov 18, 2013 09:38 AM
Swapping in new HD headache theoletts MacBook Pro 1 Feb 8, 2013 04:43 PM
Retina Headache KimMelton661 iPad 15 Oct 25, 2012 11:58 PM
malloc error farmerdoug iPhone/iPad Programming 16 Sep 21, 2012 11:42 AM
I have a headache whyapplewhy iCloud and Apple Services 3 Jul 29, 2012 09:00 PM

Forum Jump

All times are GMT -5. The time now is 04:04 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2015, MacRumors.com, LLC