Crash on u32 binary comparison

Post Reply
lnuxguy
Posts: 5
Joined: Sat Jul 19, 2008 5:12 pm

Crash on u32 binary comparison

Post by lnuxguy » Tue Nov 11, 2008 6:31 pm

I've got an SDL-based game (WiiDoom), and in the startup routines, I'm watching for button presses. The following code works:

Code: Select all

while(true)
{
  WPAD_ScanPads();
  u32 wpaddown = WPAD_ButtonsDown(0);
  if (wpaddown & WPAD_BUTTON_B) exit(0);
  if (wpaddown & WPAD_BUTTON_1) done = true;
}
No problems whatsoever. If I add a check for most other buttons (I haven't tried them all), the game crashes. For instance:

Code: Select all

if (wpaddown & WPAD_BUTTON_LEFT) x = 1;
will crash the game. Every time. I can try other buttons, or move the statement to different parts of the routine, and still crashes. If I take it back out, it works.

Ideas???

Samson
Posts: 35
Joined: Mon May 19, 2008 8:05 am

Re: Crash on u32 binary comparison

Post by Samson » Tue Nov 11, 2008 8:27 pm

Interesting. Is it possible that not the test itself is the problem, but that the extra code moves some data or other stuff to trigger a crash? Does it crash on that instruction? Did you have a look at the assembler output, if the compiler does anything weird? Did you try without optimisations?

lnuxguy
Posts: 5
Joined: Sat Jul 19, 2008 5:12 pm

Re: Crash on u32 binary comparison

Post by lnuxguy » Tue Nov 11, 2008 9:04 pm

I does seem to crash on that instruction. I've had a simple printf() and sleep() in the codeblock, and it still crashes without any screen output or sleep delay.

lnuxguy
Posts: 5
Joined: Sat Jul 19, 2008 5:12 pm

Re: Crash on u32 binary comparison

Post by lnuxguy » Wed Nov 12, 2008 1:23 am

Nevermind, I found the error:

After running the debugger (offline) on the elf and finding the function call that was crashing, it was an unrelated section of code. The weird thing is that the code that was causing the crash has been in place for a few weeks! It only started to show up once I did another button press test?

Very weird, but I'm a firm believer in that crash dump analysis. Here's a link to anyone who experiences what I just did:

http://wiibrew.org/wiki/Debugging

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest