Skip to content

Metal Sonic can cause a SIGFPE while gathering particles in BCZ2

If Metal Sonic somehow starts gathering particles right above a gather point, the game crashes with a SIGFPE. This is due to a division by zero on this line: https://git.do.srb2.org/STJr/SRB2/-/blob/next/src/p_mobj.c#L5682

This line causes the crash when missile->fuse is zero, which is caused by dist in a previous line being 0 when Metal Sonic is right above the gather point.

This is not much of an issue in the vanilla game, but it can happen in mods where gather points are placed inside the same arena as Metal Sonic.

To reproduce this crash, load into GFZ1 with this WAD: MetalSonicCrash.wad

Then, wait roughly 8 seconds.

Crash Log: srb2win.RPT