Yes, this all makes sense to me. I'm not super advanced, but I do at least understand the idea of keeping reads/writes temporally distinct. Anyway, it looks like I found the problem. There was a somewhat unnecessary (or at least easily avoidable call) happening to a method that **does** tamper with that array. I worked around it and it hasn't crashed so far. Fingers crossed. I really only need this to work for about the next hour, while I run some tests and finish my paper! ;-)
thanks for your trouble. J. On 2010-05-01, at 10:55 PM, Michael Ash wrote: > On Sun, May 2, 2010 at 1:50 AM, James Maxwell > <jbmaxw...@rubato-music.com> wrote: >>> On May 1, 2010, at 21:22, James Maxwell wrote: >>> >>>> If I drop into the debugger arbitrarily, before the crash, and check this >>>> same array, I noticed that it is nicely filled with NSCFNumbers. But, >>>> strangely, there are too many. >>> >>> My guess is that you've still got multiple threads accessing the mutable >>> array simultaneously, and that's not thread-safe if one of the accesses is >>> changing the array. >> >> Well, there's only one object that "changes" the array, so I don't know how >> this could happen. > > It's a common misconception that the only worry with thread safety is > avoiding multiple writers. > > All it takes to crash is a single write, happening simultaneous with a > read. A class that's not thread safe will not tolerate this, and can > crash. In general, multiple readers is fine, but the moment you make > any changes, you MUST not have ANY reads occurring for the duration of > the write. > > Basically, unless you know enough about multithreading to start doing > really advanced things (and when I say "really advanced", I mean the > sort of level which most people never even reach), you MUST lock (or > otherwise protect, e.g. funneling through a single thread, GCD serial > queue, etc.) ALL accesses to any shared objects. > > Mike > _______________________________________________ > > 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/jbmaxwell%40rubato-music.com > > This email sent to jbmaxw...@rubato-music.com James B Maxwell Composer/Doctoral Student School for the Contemporary Arts (SCA) School for Interactive Arts + Technology (SIAT) Simon Fraser University jbmaxw...@rubato-music.com jbmax...@sfu.ca _______________________________________________ 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 arch...@mail-archive.com