YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
21 stars 8 forks source link

Building Projects: Project attached fails to build due to "System.ArgumentOutOfRangeException: Index was out of range" in 2024.2.0 #5381

Closed gm-bug-reporter[bot] closed 5 months ago

gm-bug-reporter[bot] commented 5 months ago

Description

The attached project was last opened and run in March 2023, with what was the latest IDE and Runtime. I've just reopened it, with what is now the latest IDE and Runtime (v2024.2.0), and I get the following error at this step in the compilation process:

Writing Chunk... DFNC size ... 0.01 MB Writing Chunk... STRG size ... 0.00 MB Stats : GMA : Elapsed=526.0683 Stats : GMA : sp=41,au=0,bk=0,pt=0,sc=162,sh=6,fo=0,tl=0,ob=43,ro=14,da=0,ex=0,ma=13,fm=0x8000A21D787C02A0 System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.AggregateException: One or more errors occurred. (Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')) (Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')) (Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')) (Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')) (Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')) (Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')) ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index') at System.Collections.Generic.List1.get_Item(Int32 index) at GMAssetCompiler.GMObject.GetPropertyInParent(GMAssets a, Int32 parent, String property) at GMAssetCompiler.GMObject.GetUndefinedVariables(GMAssets a, GMObject obj, List1 variables, String value) at GMAssetCompiler.GMInstance.<>cDisplayClass98_0.b1(GMInstance inst) at System.Threading.Tasks.Parallel.<>cDisplayClass44_0`2.b1(IEnumerator& partitionState, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) --- End of stack trace from previous location ---

I do not know what's changed in the runtime or IDE since 03/2023, but something has which is now causing this issue. It could potentially be some sort of unstable variable declaration in the project that was previously handled differently, I'm not entirely sure.

Steps To Reproduce

Open the project, then try to run it (Target: Windows > GMS2 VM > Default > Default).

Which version of GameMaker are you reporting this issue for?

IDE v2024.2.0.132 Runtime v2024.2.0.163

Which operating system(s) are you seeing the problem on?

Windows 10.0.26002.0

c5fe5362-20ef-4743-926b-6583641cf9f6

rwkay commented 5 months ago

Fixed in 2024.4

EyeBallin commented 5 months ago

Well... I just spent a good hour or so trying to figure out the root cause, and right as I'm about to post my test results, you go and mark it as fixed. All that effort...

Ahh well. I'll still post it because it highlights what can and can't cause the issue, so that if anyone else was Googling the error and finding no results like me, they have something they can refer to.

@rwkay , is there a chance you'd be able to offer some more insights as to what exactly could trigger the error, and how to get around it? Below was what I found.


I've done some debugging of my own, and I've come up with an easy way to replicate the issue from scratch in a brand new project - but there are some funky twists:

  1. Make a new project.
  2. Make 3 new objects: objX, objA, and objB.
  3. Make objA the parent of objB.
  4. Add a 'Variable Definition' to objB. Call it anything, but make it of the type expression.
  5. Add one instance of each object to an empty room.
  6. Edit the 'Variable Definition' on the objB instance to be equal to the ID/name of the objX instance ("inst_XXXXXX" by default, but you can rename the objX instance, just so long as the 'Variable Definition' on the objB instance matches) 7. Run the game, and observe the igor fail.
  7. Remove the objA instance from the room, and change the parent of objB to be objX. 9. Run the game, and observe that there is no build fail.
  8. Create a fourth object, objC.
  9. Assign objC as objB's parent, and add it in to the room. This should now mirror the first test, but with objC instead of objA. 12. Run the game, and observe that there is no build fail.

I then deleted all objects, made 3 new ones (obj1, obj2, and obj3), and tried again, but even more simple:

In the second demonstration, it seems that only when a object had obj1 as its parent did it cause the build failure. Why? Who knows!

rwkay commented 5 months ago

Basically there was an incorrect range check on the index to an array - more fundamentally it was checking the wrong array (used in an older project file format, this has also been fixed)

Russell

caitlinrmcintyre commented 4 months ago

Verified fix in IDE v2024.400.0.542 Runtime v2024.400.0.561, thanks.