Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exported Version of Game Crashes at Random When Switching Scenes/Levels (slot >= slotmax) #75802

Closed
terminator98202 opened this issue Apr 7, 2023 · 7 comments · Fixed by #78987

Comments

@terminator98202
Copy link

terminator98202 commented Apr 7, 2023

Godot version

v4.0.2.stable.official.7a0977ce2

System information

Windows 10

Issue description

I started a brand new project last week and I was testing an exported version of the game just to test my scene switcher and to make sure that everything was working as intended (in a previous Godot 4 project I made the exported game would also crash randomly when switching scenes). After exporting the game and running it, the scene switcher worked great for the first few attempts, and then crashed on about the 4th scene switch. I spent hours rewriting and reformatting my code and nothing seemed to work so I deleted the project and started from scratch, rebuilding everything I had made from the ground up. After running the new game in the editor, I then exported it and ran it just to be 100% sure that everything was working. I switched levels about 10 times and it worked flawlessly. I closed the .exe and re-ran it just to make sure that it wasn't a fluke and on the 3rd level change it crashed. I spent more time trying to fix it and nothing worked so I went onto the Godot discord for help and after a few hours of discussion, I finally found the culprit:
slotmaxerror

The game runs perfectly fine in a debug export version of the game and in Godot itself, it's just the normal .exe export that's causing issues, which isn't good since that's obviously the version used for distributing the game publicly.

When I looked up the error in the Godot GitHub it became apparent that one of my resource IDs was corrupted, which shouldn't be possible considering this project is obviously a completely different project file than the first one. This is super frustrating and is clearly beyond my ability to fix and I can't continue work on my game until the issue is resolved.

Steps to reproduce

1.) Export a normal version of the game (NOT a debug export) and run it.

2.) The game starts in a top-down hub world where you use the arrow keys to move. Move towards
the flag and when you get close to it a "play" button will appear in the top left. Press it to switch scenes from the hub world to level 1.

3.) Once you're in level 1, run towards the right until you see the flag at the end of the level. Run into it to change scenes back to the hub world. (use space to jump and left and right arrow keys to move)

4.) Repeat steps 2 and 3 until you crash. Switch between scenes/levels 10 times. The game should crash before you reach 10 the first time you launch it. If you switch levels/scenes 10 times and nothing happens, close the .exe and re-launch it and try again and it should crash on the 2nd-4th scene switch. On very rare occasions the game will crash when you press the play button in the hub world.

Minimal reproduction project

slotmaxerror.zip

@RenaKunisaki
Copy link

RenaKunisaki commented Apr 16, 2023

I have what I suspect is the same crash, though I don't get the message about slots. The only relevant messages are the crash itself: (before that is only my print() statements)

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.0.1.stable.arch_linux
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /usr/lib/libc.so.6(+0x38f50) [0x7fc9d5169f50] (??:0)
[2] /usr/bin/godot(+0x474f489) [0x5557c1dd0489] (??:?)
[3] /usr/bin/godot(+0x2c3afd6) [0x5557c02bbfd6] (??:?)
[4] /usr/bin/godot(+0x2c8c0ce) [0x5557c030d0ce] (??:?)
[5] /usr/bin/godot(+0xf3c8d4) [0x5557be5bd8d4] (??:?)
[6] /usr/bin/godot(+0xee2553) [0x5557be563553] (??:?)
[7] /usr/lib/libc.so.6(+0x23790) [0x7fc9d5154790] (??:0)
[8] /usr/lib/libc.so.6(__libc_start_main+0x8a) [0x7fc9d515484a] (??:0)
[9] /usr/bin/godot(+0xef0d65) [0x5557be571d65] (??:?)
-- END OF BACKTRACE --
================================================================

It happens on the very first scene change, but not every time. I can keep launching the game and trying the scene change until it works. Once the scene has changed successfully, there are no further problems.

@Calinou
Copy link
Member

Calinou commented Apr 16, 2023

Can you try using a debug build of the release export template from https://github.com/Calinou/godot-debug-builds/releases?

You can do so by exporting your project as usual, moving the executable and the PDB file1 next to the PCK file, then runningthe project from a command prompt as follows:

godot.windows.template_release.x86_64.exe --main-pack path/to/your.pck

Then run the game until it crashes: you should get a proper backtrace now.

Debug builds haven't been updated for 4.0.1/4.0.2 yet, but this should still make it possible to reproduce the issue (most likely).

Footnotes

  1. PDB file is only relevant for Windows. Linux binaries from godot-debug-builds have debug symbols embedded.

@RenaKunisaki
Copy link

RenaKunisaki commented Apr 18, 2023

Should it be the release version rather than debug? It doesn't produce any backtrace:

$ ./godot.linuxbsd.template_release.x86_64 --main-pack ./game.pck 
Godot Engine v4.0.stable.custom_build.92bee43ad - https://godotengine.org
Vulkan API 1.3.235 - Forward+ - Using Vulkan Device #0: AMD - AMD Radeon RX 6800M
 
Font texture size: (512, 512), chr size: (32, 64)
Font texture size: (512, 512), chr size: (32, 64)
Font texture size: (512, 512), chr size: (32, 64)
Font texture size: (512, 512), chr size: (32, 64)
Font texture size: (512, 512), chr size: (32, 64)
Font texture size: (512, 512), chr size: (32, 64)
Font texture size: (512, 512), chr size: (32, 64)
Font texture size: (512, 512), chr size: (32, 64)
Font texture size: (512, 512), chr size: (32, 64)
Font texture size: (512, 512), chr size: (32, 64)
Font texture size: (512, 512), chr size: (32, 64)
Setup map 'res://maps/menu/menu.tscn', mode 0
Setup OK
Setup map 'res://maps/fish/fish.tscn', mode 1
player: player:<CharacterBody3D#37429970093>
Setup OK
Segmentation fault

The only messages (other than the segmentation fault and the first two lines) are my own print statements.

If I run game.x86_64 directly it produces a backtrace but there's only one line: [1] /usr/lib/libc.so.6(+0x38f50) [0x7fa7edc27f50] (??:0)

@Calinou
Copy link
Member

Calinou commented Apr 18, 2023

Should it be the release version rather than debug? It doesn't produce any backtrace:

You may have to run it with gdb in this case (then use bt once it segfaults).

@RenaKunisaki
Copy link

OK, here's the gdb result:

Thread 1 "godot.linuxbsd." received signal SIGSEGV, Segmentation fault.
0x0000555558ace73b in Object::notification (this=0x55555dcfd430, 
    p_notification=17, p_reversed=<optimized out>)
    at core/object/object.cpp:793
793	core/object/object.cpp: No such file or directory.
(gdb) bt
#0  0x0000555558ace73b in Object::notification (this=0x55555dcfd430, 
    p_notification=17, p_reversed=<optimized out>)
    at core/object/object.cpp:793
#1  0x0000555556b8652a in SceneTree::_notify_group_pause (
    this=this@entry=0x55555ca83830, p_group=..., 
    p_notification=p_notification@entry=17) at scene/main/scene_tree.cpp:874
#2  0x0000555556b8ca31 in SceneTree::process (this=0x55555ca83830, 
    p_time=0.0033333333333333335) at scene/main/scene_tree.cpp:466
#3  0x0000555555c51416 in Main::iteration () at main/main.cpp:3161
#4  0x0000555555bece11 in OS_LinuxBSD::run (this=this@entry=0x7fffffffd7b0)
    at platform/linuxbsd/os_linuxbsd.cpp:880
#5  0x0000555555be4b41 in main (argc=<optimized out>, argv=0x7fffffffdce8)
    at platform/linuxbsd/godot_linuxbsd.cpp:73

@YuriSizov
Copy link
Contributor

Reopening, because #78987 is getting reverted.

@YuriSizov YuriSizov reopened this Jul 31, 2023
@YuriSizov YuriSizov modified the milestones: 4.2, 4.x Nov 15, 2023
@akien-mga
Copy link
Member

Duplicate of #70910.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants