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 > stack overflow

#142549 - ingramb - Wed Oct 10, 2007 9:24 am

I'm getting data corruption based on how much data I shove into the dtcm.

With sbss_end at 0x0b002f98, my program breaks. If I move some data out of the dtcm, it works. Based on the code, stack corruption is the only thing that comes to mind (could be something else, but it sure looks like stack corruption).

So how much space should be left in the dtcm for the stack? Is there anything that can be done to track down stack issues more effectively?

#142609 - HyperHacker - Wed Oct 10, 2007 8:59 pm

Memory corruption is another possibility. Some routine is writing over your code. When you move this stuff into DTCM, the memory layout changes enough that this results in immediate breakage, whereas when it's in main RAM, the stuff that gets overwritten isn't being used at the moment, so things still seem to work fine.
_________________
I'm a PSP hacker now, but I still <3 DS.

#142616 - ingramb - Wed Oct 10, 2007 9:25 pm

I have memory in the dtcm being corrupted. The code that corrupts it doesn't touch the dtcm (except for the stack). It pretty much just passes through to fread.

So I have a value in a global array in dtcm. This array is located towards the top of the dtcm. Then I call a function that's in ram, which shuffles some local variables around and calls fread. And then the value in dtcm is corrupted (set to 0xf1f1f1f1). My fread is loading graphics, so my guess is this corrupted value is part of a gfx tile. Maybe fread is allocating a local array on the stack and copying from there to the final destination (this probly also depends on the dldi driver being used; I have a ninjapass x9).