godotengine / godot

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

Mono: Intermittent hang on game shutdown "Domain finalization timeout" #31184

Closed ForLoveOfCats closed 4 years ago

ForLoveOfCats commented 5 years ago

Godot version: Reproducible (intermittent) on both Godot Mono 3.1.1 Stable and Godot Mono master (52cfb5f5799af38e4aa543417a76999b732c3a54)

OS/device including version: Manjaro Linux x64 and Windows 10 (x64?)

Issue description: Very very rarely the game will hang on shutdown with the error

ERROR: finalize_and_unload_domain: Mono: Domain finalization timeout
   At: modules/mono/mono_gd/gd_mono.cpp:940.

image (-connect is a custom flag parsed by a game script)

Steps to reproduce: It seems to be related to the networking loosing connection to the server it is connected to (Godot high level multiplayer). Beyond that I haven't been able to reproduce it reliably enough to know anything further which is rather frustrating to be unable to provide more information.

Minimal reproduction project: I can't even reliably reproduce it let alone create a minimal project reproducing it. If anyone really wants to test this in my game project its over under SkyOfSteel

Corresponding bug on our tracker: https://github.com/ForLoveOfCats/SkyOfSteel/issues/70

ForLoveOfCats commented 5 years ago

Mono logfile here: log.txt

ForLoveOfCats commented 5 years ago

Still reproducible on latest master (ba854bbc7bb0eae230299de4da8dfcb7caf74b69)

image

Logfile

ForLoveOfCats commented 5 years ago

In the event that the cause of this cannot be determined could a reasonable workaround be implemented such that when this occurs during engine shutdown that the engine will still finish closing?

ForLoveOfCats commented 4 years ago

This is still reproducible in Godot Mono 3.2 Beta 2 on GNU/Linux x64

ForLoveOfCats commented 4 years ago

As of "recent" (I'm not quite sure what build of 3.2 this changed in) this has changed into a predictable early finalization segfault.

EDIT: This was determined to be an unrelated issue having some interesting interaction causing it to appear to be a mono issue and masking the original issue by segfaulting before the original issue can present itself.

image

As requested on Discord here is the mono logfile (with --verbose) EarlyFinalizationMonoLogfileVerbose.txt And here is the log of all that was spat into the shell (with --verbose) EarlyFinalizationShellOutputVerbose.txt

neikeq commented 4 years ago

The issue doesn't seem to happen anymore. If you start experiencing it again in the future, we will re-open. Regarding the last crash. Please open a new issue. There seems to be something wrong with ProceduralSky's worker thread. It's trying to access the MessageQueue (via call_deferred) after it was already cleaned at exit.