Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix-up DrawCircle. #111

Merged
merged 1 commit into from
Oct 4, 2022
Merged

Conversation

Clownacy
Copy link
Contributor

@Clownacy Clownacy commented Oct 4, 2022

This function was making Linux's AddressSanitizer freak out. It was also seemingly causing crashes on both PC and in my Wii U port.

In the Wii U's case, the crash would consistently occur during the PGZ->SSZ transition, while on PC it seemed to be clobbering memory related to the SDL_Renderer pointer, causing crashes at seemingly random while browsing the main menu, and also during the PGZ->SSZ transition.

Considering that the main menu uses DrawCircle quite a bit, there's a chance that this commit fixes Rubberduckycooly#106.

This function was making Linux's AddressSanitizer freak out. It was
also seemingly causing crashes on both PC and in my Wii U port.

In the Wii U's case, the crash would consistently occur during the
PGZ->SSZ transition, while on PC it seemed to be clobbering memory
related to the `SDL_Renderer` pointer, causing crashes at
seemingly random while browsing the main menu, and also during the
PGZ->SSZ transition.

Considering that the main menu uses `DrawCircle` quite a bit, there's
a chance that this commit fixes Rubberduckycooly#106.
@Rubberduckycooly
Copy link
Collaborator

I don't think #106 is fixed by this fix unfortunately

Clownacy added a commit to Clownacy/Sonic-Mania-Decompilation-Wii-U that referenced this pull request Oct 9, 2022
Ohhhhhhh where the hell do I begin with this...

Okay, so, if you complete PGZ2 while playing without Tails or
Knuckles as a sidekick and while you have a Fire Shield, then the
game will crash during the cutscene right when the first 'pulse' of
the Phantom Ruby happens.

This is caused by the shield being loaded into player 2's object
slot. The cutscene tries to update both players, mistaking the shield
for the sidekick character. This causes it to overwrite the shield's
state with player state, causing the shield player pointer to be
replaced with a pointer to a player object function. This would cause
the shield object's update function to crash the game.

The original code was able to tell that the second player slot had a
shield in it by comparing its classID to that of the first player,
but this decompilation got this incorrect and instead merely checked
that the slot wasn't empty. It also redundantly checked if the
pointer to the slot was `NULL`, which is impossible.

Correcting this fixes the crash. Good riddance, too: that bug's been
driving me crazy for over a month! I thought I'd fixed it in this
PR...

RSDKModding/RSDKv5-Decompilation#111

...but it turns out that I'd just fixed a completely unrelated bug
that, at the time, was crashing my MinGW builds.

Because the conditions to trigger this bug were so specific (have a
Fire Shield, and don't have Tails or Knuckles as a companion), I
never figured out how to consistently recreate this crash until now.

Aaaaaaaaaaaaaaaaaaaaa.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Game crashes after exiting a stage and backing out of the save menu
3 participants