godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.34k stars 20.01k forks source link

Lightmap GI headless segfault #94008

Closed unfa closed 2 weeks ago

unfa commented 1 month ago

Tested versions

Reproducible in 4.2.2 stable and v4.3.beta.custom_build.b97110cd3 (2024-07-05 14:38:10 UTC)

System information

Arch Linux + X11 + Radeon RX6800XT

Issue description

When the game is run with --headless --dedicated parameters Godot crashes seemingly as it's loading or spawning a game level.

--dedicated itself works fine, --headless also but combined they trigger the crash.

I've used prints to find out what exact line is executed when the crash happens and it's attaching the loaded and instantiated map scene to the scene tree:

@rpc("authority", "reliable", "call_remote")
func load_map():
    Logger.log(["Loading map packed scene from   ", game_config.map_scene_path], Logger.MessageType.INFO)
    if is_instance_valid(map): # refuse to load a map twice
        print("Map file already loaded, continuing")
        return

    print("1")
    var time_msec = Time.get_ticks_msec()
    print("2")
    var map_scene = load(game_config.map_scene_path)
    print("3")
    var map_instance = map_scene.instantiate()
    print("4")
    assert(map_instance is Map, "Game State loaded a map that is of type " + str(map_instance))
    print("5")
    map_instance.name = "Map"
    print("6")
    add_child(map_instance)
    print("7")
    map_instance.global_position = spatial_origin_position
    print("8")
    map = map_instance
    print("9")
    time_msec = Time.get_ticks_msec() - time_msec
    print("10")
    Logger.log(["Map loaded and spawned in", time_msec, "msec"], Logger.MessageType.SUCCESS)
    await get_tree().create_timer(REFLECTION_PROBE_RENDERING_TIMEOUT).timeout
    map_ready.emit()
    %LoadingScreen.hide()

Output:

Godot Engine v4.3.beta.custom_build.b97110cd3 (2024-07-05 14:38:10 UTC) - https://godotengine.org

Panku:<CanvasLayer#65531807086>
LynxWindowsManager:<Control#65598915955>
Booting Liblast
Found commandline arguments: ["--dedicated"]
[color=c71585]· SERVER Starting dedicated server
[color=c71585]· SERVER No map requested, using default: res://data/game/maps/city.tscn 
[color=c71585]✅ SERVER Server created
[color=c71585]ℹ SERVER Loading map packed scene from res://data/game/maps/city.tscn 
1
2
3
4
5
6

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.3.beta.custom_build (b97110cd307e4d78e20bfafe5de6c082194b2cd6)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /usr/lib/libc.so.6(+0x3cae0) [0x7a40b774eae0] (??:0)
[2] ./godot.linuxbsd.editor.x86_64(+0x465b8a1) [0x623f35a738a1] (/godot-git/./core/templates/hash_set.h:170)
[3] ./godot.linuxbsd.editor.x86_64(+0x46359ec) [0x623f35a4d9ec] (/godot-git/servers/rendering/renderer_scene_cull.cpp:1476)
[4] ./godot.linuxbsd.editor.x86_64(+0x302eb0f) [0x623f34446b0f] (/godot-git/./core/object/ref_counted.h:105)
[5] ./godot.linuxbsd.editor.x86_64(+0x4f84c00) [0x623f3639cc00] (/godot-git/core/object/object.cpp:873)
[6] ./godot.linuxbsd.editor.x86_64(+0x2a228f8) [0x623f33e3a8f8] (/godot-git/scene/main/node.cpp:264)
[7] ./godot.linuxbsd.editor.x86_64(+0x2a228d2) [0x623f33e3a8d2] (/godot-git/./core/templates/hash_map.h:456)
[8] ./godot.linuxbsd.editor.x86_64(+0x2a266f7) [0x623f33e3e6f7] (/godot-git/scene/main/node.cpp:3168)
[9] ./godot.linuxbsd.editor.x86_64(+0x2a3a636) [0x623f33e52636] (/godot-git/scene/main/node.cpp:1550)
[10] ./godot.linuxbsd.editor.x86_64(+0x2a5b804) [0x623f33e73804] (/godot-git/./core/variant/binder_common.h:304 (discriminator 3))
[11] ./godot.linuxbsd.editor.x86_64(+0xa5c994) [0x623f31e74994] (/godot-git/./core/variant/variant.h:308)
[12] ./godot.linuxbsd.editor.x86_64(+0x901324) [0x623f31d19324] (/godot-git/modules/gdscript/gdscript.cpp:2028 (discriminator 1))
[13] ./godot.linuxbsd.editor.x86_64(+0x4f85bac) [0x623f3639dbac] (/godot-git/core/object/object.cpp:786)
[14] ./godot.linuxbsd.editor.x86_64(+0x4ce7eaa) [0x623f360ffeaa] (/godot-git/core/variant/variant_call.cpp:1211 (discriminator 2))
[15] ./godot.linuxbsd.editor.x86_64(+0xa6e259) [0x623f31e86259] (/godot-git/./core/variant/variant.h:308)
[16] ./godot.linuxbsd.editor.x86_64(+0x901324) [0x623f31d19324] (/godot-git/modules/gdscript/gdscript.cpp:2028 (discriminator 1))
[17] ./godot.linuxbsd.editor.x86_64(+0x4f85bac) [0x623f3639dbac] (/godot-git/core/object/object.cpp:786)
[18] ./godot.linuxbsd.editor.x86_64(+0x4ce7eaa) [0x623f360ffeaa] (/godot-git/core/variant/variant_call.cpp:1211 (discriminator 2))
[19] ./godot.linuxbsd.editor.x86_64(+0xa6e259) [0x623f31e86259] (/godot-git/./core/variant/variant.h:308)
[20] ./godot.linuxbsd.editor.x86_64(+0x901324) [0x623f31d19324] (/godot-git/modules/gdscript/gdscript.cpp:2028 (discriminator 1))
[21] ./godot.linuxbsd.editor.x86_64(+0x4f85bac) [0x623f3639dbac] (/godot-git/core/object/object.cpp:786)
[22] ./godot.linuxbsd.editor.x86_64(+0x4ce7eaa) [0x623f360ffeaa] (/godot-git/core/variant/variant_call.cpp:1211 (discriminator 2))
[23] ./godot.linuxbsd.editor.x86_64(+0xa6e259) [0x623f31e86259] (/godot-git/./core/variant/variant.h:308)
[24] ./godot.linuxbsd.editor.x86_64(+0x901324) [0x623f31d19324] (/godot-git/modules/gdscript/gdscript.cpp:2028 (discriminator 1))
[25] ./godot.linuxbsd.editor.x86_64(+0x2a3616b) [0x623f33e4e16b] (/godot-git/./core/variant/variant.h:308)
[26] ./godot.linuxbsd.editor.x86_64(+0x4f84c00) [0x623f3639cc00] (/godot-git/core/object/object.cpp:873)
[27] ./godot.linuxbsd.editor.x86_64(+0x2a22938) [0x623f33e3a938] (/godot-git/scene/main/node.cpp:267 (discriminator 1))
[28] ./godot.linuxbsd.editor.x86_64(+0x2a266f7) [0x623f33e3e6f7] (/godot-git/scene/main/node.cpp:3168)
[29] ./godot.linuxbsd.editor.x86_64(+0x2a3a636) [0x623f33e52636] (/godot-git/scene/main/node.cpp:1550)
[30] ./godot.linuxbsd.editor.x86_64(+0x2a752e1) [0x623f33e8d2e1] (/godot-git/scene/main/scene_tree.cpp:1416)
[31] ./godot.linuxbsd.editor.x86_64(+0x2a7f518) [0x623f33e97518] (/godot-git/scene/main/scene_tree.cpp:535)
[32] ./godot.linuxbsd.editor.x86_64(+0x6a4a57) [0x623f31abca57] (/godot-git/main/main.cpp:4107)
[33] ./godot.linuxbsd.editor.x86_64(+0x60f881) [0x623f31a27881] (/godot-git/platform/linuxbsd/os_linuxbsd.cpp:962 (discriminator 1))
[34] ./godot.linuxbsd.editor.x86_64(+0x5e79a2) [0x623f319ff9a2] (/godot-git/platform/linuxbsd/godot_linuxbsd.cpp:85)
[35] /usr/lib/libc.so.6(+0x25c88) [0x7a40b7737c88] (??:0)
[36] /usr/lib/libc.so.6(__libc_start_main+0x8c) [0x7a40b7737d4c] (??:0)
[37] ./godot.linuxbsd.editor.x86_64(+0x60ce75) [0x623f31a24e75] (??:?)
-- END OF BACKTRACE --
================================================================

Steps to reproduce

  1. make sure you have git-lfs installed
  2. git clone git@codeberg.org:Liblast/Liblast.git
  3. cd ./Liblast/src/game
  4. Open the project in Godot 4.2 or later: godot --editor
  5. After the import completes, run the project like this godot --headless --dedicated

Minimal reproduction project (MRP)

So far I can't produce one.

EDIT (2024-08-03): headless-lightmap-gi-crash.zip

Video demonstration on how to use this: https://youtu.be/2PtDuEWL2P4

unfa commented 1 month ago

BTW, I also filed this issue in Liblast's issue tracker on Codeberg: https://codeberg.org/Liblast/Liblast/issues/11

unfa commented 3 weeks ago

BTW, this is still reproducible in 4.3 RC2:

Booting Liblast
Found commandline arguments: ["--dedicated"]
[color=c71585]· SERVER Starting dedicated server
[color=c71585]· SERVER No map requested, using default: res://data/game/maps/city.tscn 
[color=c71585]✅ SERVER Server created
[color=c71585]ℹ SERVER Loading map packed scene from res://data/game/maps/city.tscn 

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.3.rc2.official (3978628c6cc1227250fc6ed45c8d854d24c30c30)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /usr/lib/libc.so.6(+0x3d1d0) [0x7f5635ca01d0] (??:0)
[2] ./Godot_v4.3-rc2_linux.x86_64() [0x3ba58b1] (??:0)
[3] ./Godot_v4.3-rc2_linux.x86_64() [0x3ba67d4] (??:0)
[4] ./Godot_v4.3-rc2_linux.x86_64() [0x289a4e4] (??:0)
[5] ./Godot_v4.3-rc2_linux.x86_64() [0x42a7818] (??:0)
[6] ./Godot_v4.3-rc2_linux.x86_64() [0x22d6a8a] (??:0)
[7] ./Godot_v4.3-rc2_linux.x86_64() [0x22d6a64] (??:0)
[8] ./Godot_v4.3-rc2_linux.x86_64() [0x232ddbf] (??:0)
[9] ./Godot_v4.3-rc2_linux.x86_64() [0x232e247] (??:0)
[10] ./Godot_v4.3-rc2_linux.x86_64() [0x2388e7a] (??:0)
[11] ./Godot_v4.3-rc2_linux.x86_64() [0x7c81cd] (??:0)
[12] ./Godot_v4.3-rc2_linux.x86_64() [0x687a2c] (??:0)
[13] ./Godot_v4.3-rc2_linux.x86_64() [0x42c8a1f] (??:0)
[14] ./Godot_v4.3-rc2_linux.x86_64() [0x4113f7f] (??:0)
[15] ./Godot_v4.3-rc2_linux.x86_64() [0x7d87ae] (??:0)
[16] ./Godot_v4.3-rc2_linux.x86_64() [0x687a2c] (??:0)
[17] ./Godot_v4.3-rc2_linux.x86_64() [0x42c8a1f] (??:0)
[18] ./Godot_v4.3-rc2_linux.x86_64() [0x4113f7f] (??:0)
[19] ./Godot_v4.3-rc2_linux.x86_64() [0x7d87ae] (??:0)
[20] ./Godot_v4.3-rc2_linux.x86_64() [0x687a2c] (??:0)
[21] ./Godot_v4.3-rc2_linux.x86_64() [0x42c8a1f] (??:0)
[22] ./Godot_v4.3-rc2_linux.x86_64() [0x4113f7f] (??:0)
[23] ./Godot_v4.3-rc2_linux.x86_64() [0x7d87ae] (??:0)
[24] ./Godot_v4.3-rc2_linux.x86_64() [0x687a2c] (??:0)
[25] ./Godot_v4.3-rc2_linux.x86_64() [0x234935f] (??:0)
[26] ./Godot_v4.3-rc2_linux.x86_64() [0x42a7818] (??:0)
[27] ./Godot_v4.3-rc2_linux.x86_64() [0x22d6ab8] (??:0)
[28] ./Godot_v4.3-rc2_linux.x86_64() [0x232ddbf] (??:0)
[29] ./Godot_v4.3-rc2_linux.x86_64() [0x232e247] (??:0)
[30] ./Godot_v4.3-rc2_linux.x86_64() [0x23b8012] (??:0)
[31] ./Godot_v4.3-rc2_linux.x86_64() [0x527c34] (??:0)
[32] ./Godot_v4.3-rc2_linux.x86_64() [0x4202a2] (??:0)
[33] /usr/lib/libc.so.6(+0x25e08) [0x7f5635c88e08] (??:0)
[34] /usr/lib/libc.so.6(__libc_start_main+0x8c) [0x7f5635c88ecc] (??:0)
[35] ./Godot_v4.3-rc2_linux.x86_64() [0x43d44a] (??:0)
-- END OF BACKTRACE --
================================================================
fish: Job 1, './Godot_v4.3-rc2_linux.x86_64 -…' terminated by signal SIGABRT (Abort)
unfa commented 3 weeks ago

I've done some testing and it seems that the crash is related to LightmapGI. After removing LightmapGI node from the spawned sceene - the crash does not happen.

unfa commented 3 weeks ago

I have updated the initial post and added a link to MRP and a video demonstration on how it works:

headless-lightmap-gi-crash.zip

https://youtu.be/2PtDuEWL2P4

clayjohn commented 3 weeks ago

Sounds like it might be a duplicate of https://github.com/godotengine/godot/issues/89119

unfa commented 3 weeks ago

It does seem so, maybe my MRP will be useful in fixing this? It seems to only happen when you add an instantiated scene to the tree.

jamie-pate commented 3 weeks ago

With this build: https://github.com/godotengine/godot/pull/95103

$ ./bin/godot.linuxbsd.editor.x86_64 --path ~/build/src/godot-repros/lightmap-headless/headless-lightmap-gi-crash/ --headless
Godot Engine v4.3.rc.custom_build.3978628c6 (2024-07-31 22:06:47 UTC) - https://godotengine.org

Did not crash
Calinou commented 2 weeks ago

Closing per @jamie-pate's comment.

unfa commented 2 weeks ago

With this build: #95103

$ ./bin/godot.linuxbsd.editor.x86_64 --path ~/build/src/godot-repros/lightmap-headless/headless-lightmap-gi-crash/ --headless
Godot Engine v4.3.rc.custom_build.3978628c6 (2024-07-31 22:06:47 UTC) - https://godotengine.org

Did not crash

Great news! It'd be great to see this fix make it to 4.3 stable. If not - I guess I can make a custom build for the dedicated servers for now.,,

akien-mga commented 2 weeks ago

Well this fix is in 4.3.rc3.