-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
ASYLUM: DO NOT MERGE: Fix crash when cursor is on top of menu screen #6383
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This crash happens in a release build (--enable-release) with --disable-debug on msys2/mingw64 The crash seems to be caused by an overflow for int32 when calculating the index value in the getAngle() method, and diffY value is equal or greater than 0x800000 (ie. 2^23)
Good detective work! But maybe we could also fix it by making the calculation unsigned to begin with? Something like this, though I have only given it a quick test:
|
antoniou79
changed the title
ASYLUM: Fix crash when cursor is on top of menu screen
ASYLUM: DO NOT MERGE: Fix crash when cursor is on top of menu screen
Jan 4, 2025
antoniou79
added a commit
to antoniou79/scummvm
that referenced
this pull request
Jan 4, 2025
And also clean up code and fix eyes movement to match original This fix was proposed by eriktorbjorn in a previous PR scummvm#6383 (now closed in favor of this one). This prevents an overflow for int32 in Actor::getAngle() for the calculation of the "index" variable value, which would happen (before) when diffY would be >= 0x800000 (ie. 2^23) and was multiplied by 256 (ie. 2^8). This, in the context of the game's main menu would happen when moving the cursor to the top part of the screen. The code in getAngle() is also cleaned up to be more readable. An additional fix for the values of angleTable03[] is included, since previously it was populated by wrong hex values. What seems to have happened here was that the decimal values were wrongly entered as hex values by putting the "0x" prefix on the literal. This is a potential fix for bug ticket: https://bugs.scummvm.org/ticket/15658
closing in favor of #6385 |
antoniou79
added a commit
that referenced
this pull request
Jan 8, 2025
And also clean up code and fix eyes movement to match original This fix was proposed by eriktorbjorn in a previous PR #6383 (now closed in favor of this one). This prevents an overflow for int32 in Actor::getAngle() for the calculation of the "index" variable value, which would happen (before) when diffY would be >= 0x800000 (ie. 2^23) and was multiplied by 256 (ie. 2^8). This, in the context of the game's main menu would happen when moving the cursor to the top part of the screen. The code in getAngle() is also cleaned up to be more readable. An additional fix for the values of angleTable03[] is included, since previously it was populated by wrong hex values. What seems to have happened here was that the decimal values were wrongly entered as hex values by putting the "0x" prefix on the literal. This is a potential fix for bug ticket: https://bugs.scummvm.org/ticket/15658
antoniou79
added a commit
that referenced
this pull request
Jan 9, 2025
And also clean up code and fix eyes movement to match original This fix was proposed by eriktorbjorn in a previous PR #6383 (now closed in favor of this one). This prevents an overflow for int32 in Actor::getAngle() for the calculation of the "index" variable value, which would happen (before) when diffY would be >= 0x800000 (ie. 2^23) and was multiplied by 256 (ie. 2^8). This, in the context of the game's main menu would happen when moving the cursor to the top part of the screen. The code in getAngle() is also cleaned up to be more readable. An additional fix for the values of angleTable03[] is included, since previously it was populated by wrong hex values. What seems to have happened here was that the decimal values were wrongly entered as hex values by putting the "0x" prefix on the literal. This is a potential fix for bug ticket: https://bugs.scummvm.org/ticket/15658
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 crash happens in a release build (--enable-release) with --disable-debug on msys2/mingw64
The crash seems to be caused by an overflow for int32 when calculating the index value in the getAngle() method, and diffY value is equal or greater than 0x800000 (ie. 2^23)
The Actor::getAngle() method in the context of the in-game menu (called from Menu::update()) is used for calculating the correct "frame" for the eyes in the center of the screen which are supposed to follow the cursor movement. The getAngle() method is also used elsewhere in the engine (called from Actor::faceTarget()), so this fix should be tested so that it has no side-effects in that part of the code.
This is a potential fix for this bug ticket: https://bugs.scummvm.org/ticket/15658
Edit: Please do not merge. Currently exploring an alternative fix that will also bring behavior closer to the original