Loading...

xcode-users@lists.apple.com

[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: EXC_BAD_ACCESS error Andreas Grosam Wed Oct 13 09:00:46 2010

On Oct 11, 2010, at 3:49 PM, McLaughlin, Michael P. wrote:

> Using Xcode 3.2.4 under Mac OS 10.6.4 on a 64-bit Mac Pro, I am getting a
> runtime error of
> 
> EXC_BAD_ACCESS
> 
> The project is a C++/CoreServices tool.  The error seems to arise because
> some legacy (Mersenne Twister) code is trying to dereference a pointer with
> a negative index.
> 
> for (j = M;--j;p++)
>   *p = p[M-N] ^ TWIST(p[0], p[1]);     // M = 397, N = 624
> 
> However, the underlying algorithm is really OK and, in fact, I do *not* get
> this error with exactly the same code when it is part of another
> Cocoa/Objective-C++ project.

Maybe this is unlikely, but did you check this:
Before you enter this for loop (there are two in the state generator function), 
you need to initialize the pointer p properly. According the Mersenne Twister 
algorithm, this should be:

p = &state[N - M];

where state is the state array, which you have defined and which has N elements.

And M and N shall be signed int constants.


best

> 
> Can anyone shed any light on this?  I have used this code for a long time
> and have never gotten this error before.
> 
> I tried to look at the Build Results but that window says only "Build
> Succeeded" and there seems to be no icon (that I could find) that will bring
> up the gcc build command unless there is some warning or compile error.
> 
> Thanks for any tips.
> 
> -- 
> Mike McLaughlin
> 
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list      ([EMAIL PROTECTED])
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/xcode-users/agrosam%40onlinehome.de
> 
> This email sent to [EMAIL PROTECTED]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      ([EMAIL PROTECTED])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/xcode-users/alexiscircle%40gmail.com

This email sent to [EMAIL PROTECTED]