[Bugfix] Move Heaps_Free after DeinitOTR in SDL_main#3279
[Bugfix] Move Heaps_Free after DeinitOTR in SDL_main#3279garrettjoecox merged 1 commit intoHarbourMasters:developfrom
Heaps_Free after DeinitOTR in SDL_main#3279Conversation
Archez
left a comment
There was a problem hiding this comment.
Seems good enough to me 👍
I wonder if maybe we should also set system globals to NULL like gPlayState, but I don't know what all is managed by the system heap and that doesn't need to happen in this PR.
|
|
|
It doesn't right now, the problem was exposed when DeinitOTR was calling a destruct function in Anchor using the |
|
Is |
|
As a matter of fact, it isn't. |
|
Knowing this now, this might also be related to my issues with certain hooks not getting called in the process of closing SoH in the middle of a game. |
|
Heck, that might even be why Proxy felt the need to call the Anchor deinit function in |
|
I agree this can still be merged since it doesn't break anything and will continue to not break anything after a better fix is found. |
|
Should |
|
I could see doing that just for consistency's sake. |
|
Does |
|
Doesn't look like it. It only uses defines for sizes, and they're assigned to variables in heaps.c, and moving it to the top of Main() didn't prevent it from running. |
…s_Alloc` before and outside of `Main`.
d0e630d to
7760756
Compare
Anchor was having some issues with accessing a non-null, garbage
gPlayStatefromDeinitOTRas part of cleanup when closing while the game was running, causing a crash on closing. This was caused byHeaps_FreeinMaindeallocating the memory forgPlayStatewithout making its pointer null. This PR movesHeaps_FreeafterDeinitOTRinSDL_mainso all closing/cleanup operations can be done without worrying about non-null garbage pointers/references.I took this approach instead of moving
DeinitOTRinsideMainbeforeHeaps_Freeas I figured there was probably a reason Deinit wasn't added inside Main in the first place, and this provides a better model for adding anything else that we might need in the future beforeHeaps_Free.Build Artifacts