Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This aliasing bug crashes gob3 in retroarch when compiled with -O3 optimization after the intro is shown and the goblin stretches in the first scene of the game.
This is due to gcc treating the local pointers oldNestLevel, oldBreakFrom, and oldCaptureCounter as aliases of the pointers in the _vm structure when -O3 optimization is enabled.
However, it appears to only lead to fault behavior within the libretro_scummvm core. After investigation, I determined the crash is due to these pointers being backed by xmm registers (specifically oldBreakFrom in the build I was using) which get clobbered in some cases due to the aliasing optimizations.
More specifically, within Retroarch one of the xmm registers that is used as backing for this variable get clobbered when the slowmotion_ratio is set on this line of code. This is then treated as the 'original' pointer address which ultimately leads to a deference of an invalid memory address later.
For whatever reason, these xmm registers don't appear to get clobbered in standalone scummvm. I speculate that it may only result in a fault when LIBCO is utilized for threading -- which is the case with the libretro core. I did disassemble the standalone version of scummvm as well, and it does use the xmm registers as backing; however, they don't end up clobbered.
The issue should be replicable using gob3 with:
Note, I did not test a Linux build or other architectures.