bates64 / papermario-dx

Base for Paper Mario romhacks
82 stars 26 forks source link

fx_aura() crash #95

Closed JCog closed 1 month ago

JCog commented 1 month ago

Any time fx_aura() is used, the game crashes with a segfault in osInvalICache(). This includes the intro sequence, Fire Shell, Master 3, and Final Bowser. Backtracing from a crash on Bowser gives me the following:

Program received signal SIGSEGV, Segmentation fault.
0x80069bd8 in osInvalICache ()
(gdb) bt
#0  0x80069bd8 in osInvalICache ()
#1  0x800293e0 in dma_copy (romStart=0x383f00 "", romEnd=<optimized out>, vramDest=0xe0076000 <aura_main>) at src/43F0.c:444
#2  0x800628a0 in load_effect (effectIndex=59) at src/effects.c:326
#3  0x8007913c in fx_aura ()
#4  0x80043e64 in npc_update_decoration_bowser_aura (npc=0x804eb7e0, idx=0) at src/npc.c:1824
#5  0x80043d18 in npc_update_decorations (npc=0x804eb7e0) at src/npc.c:1777
#6  0x800410f4 in update_npcs () at src/npc.c:725
#7  0x8003d7a0 in state_step_world () at src/state_world.c:23
#8  0x800266f8 in step_game_loop () at src/main_loop.c:99
#9  0x800260f4 in gfxRetrace_Callback (gfxTaskNum=0) at src/main.c:122
#10 0x800686d4 in gfxThread (data=<optimized out>) at src/os/nusys/nugfxthread.c:32
#11 0x80073780 in __osDispatchThread ()

This doesn't seem to happen with the vanilla repo using --shift and --modern-gcc, so I assume something must have been changed that broke this, but beyond that I have no idea what's going on.

JCog commented 1 month ago

Okay I did at least manage to figure out the the issue started with 88687e1d8d724b6dfa5bf6cc983632766cc7b67e. Still not sure what's going on, but that's definitely where the problem is.

bates64 commented 1 month ago

That commit added the flags -DNON_MATCHING and -DAVOID_UB. If I were a betting man I'd say they're the cause

JCog commented 1 month ago

Well I made a little bit more progress here. Any effect that tries to dma_copy() something more than 0x1000 bytes crashes. Looping through gEffectTable, there are two more effects that do so: EFFECT_TUBBA_HEART_ATTACK and EFFECT_FIREWORK_ROCKET. I don't know why that's the limit though.

Every single effect (except for EFFECT_QUIZMO_ANSWER, oddly) is bigger in dx than building vanilla with --shift and --modern-gcc by varying amounts. I also don't know why this is, but my guess is that that's the underlying cause here.

As a side note, this seems to be the cause of #67.

bates64 commented 1 month ago

Effects being bigger than vanilla is definitely unintended, but I worry about that upper limit. @rainchus is likely to know more about this