Skip to content

Potential fix for Montezuma Revenge segmentation fault#670

Closed
Sebastian-Griesbach wants to merge 2 commits intoFarama-Foundation:masterfrom
Sebastian-Griesbach:fix-MontezumaRevenge_segfault
Closed

Potential fix for Montezuma Revenge segmentation fault#670
Sebastian-Griesbach wants to merge 2 commits intoFarama-Foundation:masterfrom
Sebastian-Griesbach:fix-MontezumaRevenge_segfault

Conversation

@Sebastian-Griesbach
Copy link
Copy Markdown

Issue #11 has been a long standing issue. I recently ran into segmentation faults when using Montezuma Revenge such that it seemed reasonable to assume that this is the same issue.

However here is a problem. I am unable to verify that this snippet is causing the issue. Because I am unable to reliably reproduce the bug in the first place. The description of it in the issue no longer seems to be working, yet I can regularly observer segmentation faults only when using Montezuma Revenge as an environment.

Heavily assisted by an coding agent I could identify this potential issue.
Here are fives variables myPOSP0, myPOSP2, myPOSM0, myPOSM1andmyPOSBL`.
These variables are supposed to be constrained to the range [0,159], the original code uses two if cases to check if first it is larger than 160 if so subtract 160 and if it is smaller then 0 to add 160. This does not work if the value as already deviated so much that adding or subtracting 160 is not enough, e.g. if the value would be 350, we would subtract 160 and arrive at 190 which will then not be changed anymore and later on causes a segmentation fault.
I propose to change this to use modulo operations instead such that this operation will land in the intended interval regardless of how far away the incoming value is.

While I can not guarantee that this actually fixes the segmentation fault I'd argue that this is keeping the intended behavior and is excluding an edge cases. Even if this is not fixing the segmentation fault there should be no adverse effects connected to fixing this little oversight.
Looking forward to hear what you think.

Unable to reliably reproduce error thus unable to verify that this fixes it
@Sebastian-Griesbach
Copy link
Copy Markdown
Author

I missed that someone already made a Pull request for this... #668

withdrawing mine.

@josephdviviano
Copy link
Copy Markdown

The funny thing is I only got involved because of Lucas Beyer's tweet

https://x.com/giffmana/status/2020998227886027095?s=20

@Sebastian-Griesbach
Copy link
Copy Markdown
Author

The funny thing is I only got involved because of Lucas Beyer's tweet

https://x.com/giffmana/status/2020998227886027095?s=20

Lol, thank you for sharing

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.

2 participants