Threads + Garbage Collection = Crash?
Threads + Garbage Collection = Crash?
- Subject: Threads + Garbage Collection = Crash?
- From: "Oleg Krupnov" <email@hidden>
- Date: Wed, 1 Oct 2008 15:35:43 +0300
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
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?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden