YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
24 stars 8 forks source link

A large number of assignments in the same function hard-crashes the runtime #6959

Open colinator27 opened 3 months ago

colinator27 commented 3 months ago

Description

Having what seems to be a little over 4000 assignments in one function is enough to crash GMRT only in Interpreter mode, and having many more assignments (in the sample project, 65536 of them) is enough to crash GMRT in Native mode as well.

This is a little bit silly (I came up with this while testing GMRT's limits), but it feels strange to be inconsistent. Since I could see some projects using a few thousand lines of code to store data, I felt like I should report this, in case it's not already known. This was tested in GMRT 0.8.0, using Beta IDE 2024.600.0.576.

Sample project: VeryLargeFunctionTests.zip

Expected Change

Ideally no limitation on the number of statements; otherwise, a consistent build error would be nice

Steps To Reproduce

Run attached sample project in Interpreter mode, and see the following output:

running tests... starting pretty_large

(followed by a silent crash)

Then, run the same project in Native mode, and see the following output:

running tests... starting pretty_large
finished pretty large function
starting very_large

(followed by a silent crash)

How reliably can you recreate this issue using your steps above?

Always

Which version of GameMaker are you reporting this issue for?

Beta (Please put the exact version number in your Description)

Which platform(s) are you seeing the problem on?

Windows

Compiler Log File

Sample .yyz File

andy-yoyo commented 3 months ago

Thanks for filing this and providing the convenient test cases 👍

There are at least three things happening here:

  1. A bug in the compiler which means registers aren't reclaimed properly from some instructions, expanding the size of the stack frame
    • These issues should be ironed out soon, and will resolve the specific examples in this issue
  2. A limitation in the first version of the GMRT interpreter, where the stack has a fixed size limit which is fairly low (it fits 4096 values, as you might have guessed)
    • This is a known issue. Dynamic stack expansion didn't make it into the first release, but should be implemented soon.
  3. A limitation in the compiler, which says each function can only have a maximum of 2^16 constants and 2^16 registers.
    • In normal code these limits should be very hard to hit (especially after fixing the first item in this list)
    • We will eventually remove these limits anyway, for the sake of generated code and any other surprising edge cases

I will update this issue again when one of the first two issues is fixed (the third one is lower priority for now, unless it causes trouble in some existing projects even after the other issues are fixed)