YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
24 stars 8 forks source link

[YYC] Garbage collector causes a silent crash with access violation (-1073741819) and variable disappearing from the struct #2627

Closed KeeVeeGames closed 10 months ago

KeeVeeGames commented 10 months ago

Description

I am not sure if these two bugs are related, but taking into account the similarity of their conditions and the fact that they happen on the same project (so no need to send it two times) I posted them in one issue. Sorry for the possible inconvenience in future tracking.

There are occasional silent crashes and struct corruptions in my project. I wasn't able to reproduce them on a smaller scale so I had to send the full game instead.

The silent crash happens after going into the level room from the level selection menu. It yields the -1073741819 status error in Output without any exceptions. After debugging in Visual Studio I concluded that it's related to garbage collector, specifically to the MarkAndSweepGen function. The issue is not observed with the gc_enable(false) and manual gc_collects. More info: https://forum.gamemaker.io/index.php?threads/2023-11-release-thread.107587/post-649403

The second bug is causing a static method variable to "disappear" from the constructor. After re-entering the room (if the first crash hasn't happened) an exception will be raised with the "Unable to get variable setRGB from object ..." although the variable definitely should be in that object. It's most certainly not a coding mistake and possibly also related to the garbage collector because it's not observed in VM and disappears with the GC disabled in the same fashion as the issue above.

Possible relation to #1910, #1617, #2253, https://forum.gamemaker.io/index.php?threads/how-to-debug-a-crash-that-doesnt-leave-an-error.101560/post-613634

Steps To Reproduce

  1. Compile the game with YYC
  2. Press the play button in the center
  3. Choose a level by pressing a button with a letter (A for example)
  4. Expect a crash a. Crash isn't 100% reproducible and you may need to close the game and re-run it again for it to eventually happen
  5. Regarding the second bug, if the first crash hasn't happened you can try to raise the second one which seems to be more frequent: a. Press Escape to pause the game b. Choose "Quit" option c. Start the game again on any level d. Get the exception "Unable to get variable setRGB from object ..."

5f4c8c2a-6ba7-466c-a882-f82d850e0793

stravee commented 10 months ago

I also have a similar issue with arrays+structs (I'm assuming) in VM: having the garbage collector enabled by default produces some random silent crashes in VM, while disabling it fixes the issue.

I haven't gotten so in depth as the original poster and I'm trying to narrow it down and get it into a small project for reporting.

rwkay commented 10 months ago

It looks like the issue here is caused by the construct foo ??= new Obj() not being handled correctly by the compiler. if you want to avoid that just now it would be a good idea

yymrennie commented 10 months ago

gh-gmb-2627_nullish_newobject.zip

This is a simpler sample which isolates the problem - it doesn't actually crash but we can more easily see what's going wrong internally with this.

yymrennie commented 10 months ago

Fixed in 2024.2

caitlinrmcintyre commented 9 months ago

Verified fix in IDE v2024.200.0.461 Runtime v2024.200.0.477, thanks.