Re: Class gets EXC_BAD_ACCESS only as NSOperation
Re: Class gets EXC_BAD_ACCESS only as NSOperation
- Subject: Re: Class gets EXC_BAD_ACCESS only as NSOperation
- From: Bill Bumgarner <email@hidden>
- Date: Tue, 24 Mar 2009 09:04:56 -0700
On Mar 24, 2009, at 8:22 AM, James Maxwell wrote:
int sliceCount = [pitchSlices count];
float midiEventsToHTM[sliceCount][20];
float rhythmEventsToHTM[sliceCount][20];
....
The rhythmEventsToHTM array is the one that's getting the bad access
error, and I can NSLog the rhythmSlices NSArray without issue. The
other thing that seems very weird is that, if I just run the
midiEventsToHTM data (i.e., commenting out anything to do with
"rhythm") it runs fine in ... the NSOperation thread.
How big is sliceCount?
Threads typically have pretty darned small stack limits. The two
float arrays above are both allocated on the stack. Thus, you are
reserving (sliceCount * 20 * sizeof(float) * 2) bytes worth of space
on the stack.
That the crash goes away when you only run w/one array and that the
crash happens always on accessing the second array for the first time
in the loop indicates that this is quite likely the case.
In general, creating really large buffers on the stack is risky.
Move the arrays to the heap and the problem will quite likely be fixed.
b.bum
_______________________________________________
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