gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Need help with a Bizzare bug

#166170 - albinofrenchy - Sun Feb 01, 2009 10:10 am

Unfortunately I don't think I can sheer this down to manageable copy-paste size; but I was wondering if anyone here can give me pointers how to fix this problem.

I have some code that I ported to the ARM processor that in general seems to do what it is supposed to . However, I think its seriously screwing up my stack in the process.

If I run something like:

Code:

int main(void) {
   fz_matrix ctm;
   fz_error * error;
   fatInitDefault();
   fz_cpudetect();
   fz_accelerate();
   consoleDemoInit();
   some_pdf_init_code();
   ctm = viewctm();
   error = some_render_code(...);
   if(false)
      printf("CTM: %p", &ctm);
   return 0;
}

It will crash NO$.

If I comment out the bottom

Code:

if(false)
   printf("CTM: %p", &ctm);


it works.

If I make the ctm variable static it works as well.

An interesting note is that I can display the image that is rendered with no problem. It just seems to happen whenever I try to access variables in the scope of my function. So that certainly points to a broken stack; but the fact that the code never runs has me puzzled.

Anyone with any ideas on what this could possibly be? I'm utterly confused; I can not think of a single reason that code that will NOT run is crashing NO$ (and my DS).

#166171 - Echo49 - Sun Feb 01, 2009 10:34 am

Which line is No$gba crashing on?

#166172 - albinofrenchy - Sun Feb 01, 2009 10:41 am

No way to be sure; I have only the freeware version of NO$ (I only started working with the DS last week and I am unclear as to if the NO$ guy is still releasing anything)

It doesn't crash in NDESMUME.

#166175 - Maxxie - Sun Feb 01, 2009 12:19 pm

albinofrenchy wrote:
It doesn't crash in NDESMUME.


Which version?
May i point you to http://desmume.org/ ?
_________________
Trying to bring more detail into understanding the wireless hardware

#166177 - albinofrenchy - Sun Feb 01, 2009 1:27 pm

It does not crash .9, nor does it crash .7 with gdb support.

#166202 - Echo49 - Sun Feb 01, 2009 10:22 pm

You can find out which line it's crashing on by putting a while(1); at the end of each line.

#166205 - silent_code - Sun Feb 01, 2009 10:35 pm

Echo49 wrote:
You can find out which line it's crashing on by putting a while(1); at the end of each line.
... adn removing them one by one.

Otherwise there's still good old logging (unbuffered or buffered and immediately flushed), in case you can't get a debugger to work. :^)
_________________
July 5th 08: "Volumetric Shadow Demo" 1.6.0 (final) source released
June 5th 08: "Zombie NDS" WIP released!
It's all on my page, just click WWW below.