-
Notifications
You must be signed in to change notification settings - Fork 114
Description
Nomi CEu Version
1.7.7
Launcher
Prism Launcher
Configurations or Mods Changed
No response
Environment
Singleplayer
Mode
Both Modes
What Happened
The game hangs after opening the crafting status in any AE2 terminal with item access
Expected Behavior
The crafting GUI shows correctly or gets truncated
Reproduction Steps
- Set the window size to exactly 854*480 in the launcher and don't resize
- Launch the game
- Open a world with an AE2 network with crafting processors
- Open the "Crafting Status" menu in a terminal
- The game crashes and recovers
Logs
Additional Information
This is likely caused by HEI trying to show items in a negative amount of space
- The game starts rendering the inventory GUI
- The crafting status GUI takes up more space than there's available
- Since the amount of space is negative, the calculated number of bookmark items to display is negative too
- The bookmark rendering loop tries to reach negative amount of bookmarks to draw
- Since the amount of bookmarks can't really be negative, it will overflow if there's enough RAM to store (very unlikely)
- The amount of bookmarks that are to be shown is dictated by formula (((width * pitch) mod (2^32)) + 2^32 ) mod 2^32
- Since the amount is above 4 billion, the amount of memory required to store the bookmarks is circa 16 gigabytes, not counting other collections
- This greatly exceeds recommended amount of RAM in the modpage
- Since the allocation is to exceed amount of RAM, it fails with
java.lang.OutOfMemoryError: Java heap space - LoliASM catches the error
- LoliASM displays the crash page
The hang before crash is due to insane amount of items that are added to the collections
Looking at the mezz.jei.render.BookmarkListBatchRenderer.sizePages(BookmarkListBatchRenderer.java:101), there is only one statement that leaves the method: https://github.com/CleanroomMC/HadEnoughItems/blob/99160badf675a128ae420b04e707b6e67860c463/src/main/java/mezz/jei/render/BookmarkListBatchRenderer.java#L97. If slots is not empty, there are bookmarks and the current row slots.get(rowIndex) is empty, the only exit statement will not have chance to run, and thus the method enters an infinite loop. This can be remediated by checking each row and skipping the row if the row happens to have 0 width.
Since the method is now doomed to run infinitely, RAM usage will inevitably climb without an end and thus the method throws a critical error. It is only caught by LoliASM and thus the game does not crash to desktop.
I hope that this helps fix the bug.