> In my application, I create a (single) background thread, for creating
> thumbnail images. I use NSRunLoop and - [NSObject
> performSelector:onThread:withObject:waitUntilDone:] to communicate
> between the main and the background threads.
>
> I am experiencing weird random crashes with the following log:
>
> IconView(49550,0xb0103000) malloc: free_garbage: garbage ptr =
> 0x1239260, has non-zero refcount = 1

This first message I've seen in my own programs and even in Xcode's logs.
>From what I've been able to track down about it, it is a notice about what
would have been a leak in one of Apple's frameworks that is being caught
by GC.

As for your crashes I think I can offer some advice. If you're not doing
any mallocs then most likely you're passing objects back to your main
thread through some shared space, possibly via contextInfo:

I've seen in my own GC programs using threads that occasionally the
collector (usually during high object usage) will collect objects that are
in transit unless you CFRetain them in your thread before sending and then
CFRelease them in the other thread once you've assigned them to a gc-ed
storage variable.

If you are using malloc'ed memory anywhere to store GC-ed variables you
should really be using NSAllocateCollectable with the NSScannedOption to
allocate that memory and declare it as __strong. Otherwise, the collector
may reclaim the objects stored there if that's the only memory location
where they are stored during its collection phase.


> IconView(49550,0xb0103000) malloc: *** free() called with 0x1bdcf6b0
> with refcount 0
> IconView(49550,0xb0103000) malloc: *** auto malloc[49550]: agc error
> for object 0x1bdcf6b0: Deallocating a non-block
>
> My application relies heavily on garbage collection (the gc required
> mode), so I never call malloc/free explicitly. I don't create
> NSAutoreleasePool in the background thread's main method.
>
> I set breakpoint on malloc_printf and I see the following stack trace:
> malloc_printf
> autocollect_internal
> autocollection_thread
> _pthread_start
> thread_start.
>
> I have noticed that these crashes occur more often when the workload
> is high - i.e. there are many sequential requests to the background
> thread.
>
> Also, I have located a piece of code in the main thread such that when
> I comment it out, the crash disappears, although the code fragment has
> absolutely nothing to do with the background thread. It actually fills
> a round rect with a gradient fill, in the main thread. Funny enough,
> when the rect is square, not round, the bug also disappears.
>
> I don't use NSOpenPanel in my application.
>
> I have exhausted all my versions about what could be wrong. Any ideas?


-- 
Ashley Clark

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to