Page 1 of 1

Weird program crashes (DSI exception)

Posted: Mon Jan 12, 2009 4:33 pm
by Eke
Hi,

I'm recently facing some odd program crash and I have very hard time figuring what's wrong: the problem is that only modifying some piece of code or even adding "dead code" sometime prevent crash from occuring, and from analysing the added code deeply, it is perfecly fine and there should not be any crash

From the debugging exception screen, I got the location of the crash:

0x800d1708-> ...

using gdb, I got the incriminated line of code:

Code: Select all

FramesPerSecond = RenderedFrameCount;
FramesPerSecond is a global variable
RenderedFrameCount is a local variable for the main() function

IDA disassembler gives me the incriminated instruction:

Code: Select all

stw     %r27, FramesPerSecond@l(%r21)

The problem is that, according to the debugging exception screen, when the crash occurs, we got:

%r21 = 0x3F800000
%r27 = 0x3c (=60, which is the expected value)

From what I understood from PPC assembly, r21 should hold the address of FramesPerSecond, and what happen is that the value $3C iw written at the address @0x3F800000, resulting in a crash, is that right ?

Now, in that case, how the hell could r21 been corupted that way ? Is it a bug from the compiler somewhere else ? a stack overflow in a subroutine called just before ?

R21 is initialized that way from code disassembly:

Code: Select all

lis     %r21, FramesPerSecond@h
Any help or advice would be appreciated, this is getting a really annoying problem :roll:


EDIT: this was indeed a stack overflow issue, passing parameters in function instead of using globals somehow fixed the issue