Re: My try/catch block isn't catching exceptions on 10.6
Re: My try/catch block isn't catching exceptions on 10.6
- Subject: Re: My try/catch block isn't catching exceptions on 10.6
- From: Dave Keck <email@hidden>
- Date: Thu, 26 Nov 2009 20:10:21 -0500
> PS. Yes, I know there are faster and more efficient ways to enumerate an
> array, but the old-school 'for' loop approach still comes to mind first and
> I still prefer it for small arrays.
Overlooking the speed benefits, fast enumeration will also throw an
exception if the array you're enumerating is modified while doing so,
which surely improves anyone's code.
> Exception Type: EXC_BAD_ACCESS (SIGBUS)
This is not a friendly, catchable Objective-C exception - it's a Unix
signal sent to your process due to a memory access problem (see
http://en.wikipedia.org/wiki/Bus_error.) Rarely should you attempt to
recover from a signal - it's usually a symptom of a bug in your code,
and in your case, it certainly is.
After a cursory reading of your code it looks like you're dealing with
a threading issue involving myItemList or imminentList. Your comment
mentions "We don't really care if imminentList changes because the
dictionary object will always be there even if the contents aren't."
Does this mean you're modifying imminentList from one thread while
another is attempting to read from it? If so, you need a lock around
the reads and writes.
I think you'd benefit from reading this, if you haven't already
(particularly the bit under the "Mutable Versus Immutable" header):
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html.
_______________________________________________
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