Skip to content

[BUG] Nomifactory CEu will crash reliably when opening crafting status with a small window #1519

@Monniasza

Description

@Monniasza

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

  1. Set the window size to exactly 854*480 in the launcher and don't resize
  2. Launch the game
  3. Open a world with an AE2 network with crafting processors
  4. Open the "Crafting Status" menu in a terminal
  5. The game crashes and recovers

Logs

https://mclo.gs/7H2Kv4s

Additional Information

This is likely caused by HEI trying to show items in a negative amount of space

  1. The game starts rendering the inventory GUI
  2. The crafting status GUI takes up more space than there's available
  3. Since the amount of space is negative, the calculated number of bookmark items to display is negative too
  4. The bookmark rendering loop tries to reach negative amount of bookmarks to draw
  5. Since the amount of bookmarks can't really be negative, it will overflow if there's enough RAM to store (very unlikely)
  6. The amount of bookmarks that are to be shown is dictated by formula (((width * pitch) mod (2^32)) + 2^32 ) mod 2^32
  7. Since the amount is above 4 billion, the amount of memory required to store the bookmarks is circa 16 gigabytes, not counting other collections
  8. This greatly exceeds recommended amount of RAM in the modpage
  9. Since the allocation is to exceed amount of RAM, it fails with java.lang.OutOfMemoryError: Java heap space
  10. LoliASM catches the error
  11. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions