EXC_BAD_ACCESS errors in OSX / related to SDL?

Can someone describe some common circumstances under which this error
occurs for SDL apps in Mac OSX? I’m working on Stella (multi-platform
Atari 2600 emulator), and except for some minor system-specific
classes, the codebase is 99% across all platforms. Google seems to
suggest that it’s thread related, but since I don’t explicitly use
threads, it sort of falls to SDL. Here’s the exact error:

Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_INVALID_ADDRESS (0x0001) at 0x060b1f8e

Note that I can’t replicate this on either an Intel iMac or a G5
PowerMac, but I’m getting users reporting it on a Macbook and a G5
iMac. D?!m you Apple for creating so many different
machines/CPUs/configurations to test. Note that I’ve never seen
anything similar on Linux/GP2x/WinCE/Win32/OS2 (the other platforms
that use this same codebase).

Is this even an SDL error??

Thanks,
Steve

Hello Stephen,

Sunday, December 17, 2006, 1:12:19 AM, you wrote:

Can someone describe some common circumstances under which this error
occurs for SDL apps in Mac OSX? I’m working on Stella (multi-platform
Atari 2600 emulator), and except for some minor system-specific
classes, the codebase is 99% across all platforms. Google seems to
suggest that it’s thread related, but since I don’t explicitly use
threads, it sort of falls to SDL. Here’s the exact error:

Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_INVALID_ADDRESS (0x0001) at 0x060b1f8e

That just means that your app crashed due to accessing memory it
hasn’t allocated. It’s too vague to tell whether that’s your apps
fault or SDL’s fault.

Look at the crashlog and see which thread crashed and where it
crashed. Make sure you have debug symbols attached.–
Best regards,
Peter mailto:@Peter_Mulholland

Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_INVALID_ADDRESS (0x0001) at 0x060b1f8e

This error means you try to access memory not allocated.

It has nothing to do with threads.

Note that I can’t replicate this on either an Intel iMac or a G5
PowerMac, but I’m getting users reporting it on a Macbook and a G5
iMac. D?!m you Apple for creating so many different
machines/CPUs/configurations to test.

You are kidding me? Apple vs Windows market. I think it’s 100 vs
billion of config.

And the error above has nothing to do with the architercture, it is
a programme bug.

Note that I’ve never seen
anything similar on Linux/GP2x/WinCE/Win32/OS2 (the other platforms
that use this same codebase).

The memory errors are quite vicious, because sometime, you can do an
error, and this error has no consequence.

I mean, you can do something like:

int *a = malloc(length * 4);
instead of
int *a = malloc(length * sizeof(int)); // Or sizeof(*a)

And this will lead to problem only on 64 bit machines.

You can also do something like:

afunc(float **v) {
float *a, *b;
*a = 3.2;
*b = 5.5;
v[0] = &a;
v[1] = &b;
}

main() {
float **v = malloc(10 * sizeof(float *));
afunc(v);
printf("%f\n", *v[0]);
printf("%f\n", *v[1]);
}

I often see error like this. And, the funny things, is it working…
until an error occur. And depending of the implementation, and the
rest of your code. The error can never appear.

So, in your case, it’s very difficult to tell. But with bad coding,
any function in your code can trigger the error. And SDL is likely to
do so.

You should debug your app to see where the flaw is.

Best regardsOn 17 Dec 2006, at 02:12, Stephen Anthony wrote:


Kuon
CEO - Goyman.com SA
http://www.goyman.com/

“Computers should not stop working when the users’ brain does.”

-------------- next part --------------
A non-text attachment was scrubbed…
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2434 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20061217/d8164a1d/attachment.bin