godot: Crashes when calling C# code from a gdscript thread

Godot version: 7610409b8a14b8499763efa76578795c755a846d

OS/device including version: Mobile gtx 1660ti, latest nvidia drivers, gles2 Windows 10 - Insider edition

Issue description: When calling C# from a gdscript in a thread it crashes on startup. The expected result is for it to not crash.

Steps to reproduce: Create a simple scene with a node with a gdscript that opens a thread and calls c# code on that thread. Launch scene and it crashes with the following error:

Mono: Log file is: 'C:\Users\muevo\AppData\Roaming/Godot/mono/mono_logs/2021-05-31_17.08.21_3516.log'                   ERROR: GDMonoLog::mono_log_callback: Mono: FATAL ERROR '* Assertion at ..\mono\mini\debugger-agent.c:4175, condition `!tls' not met                                                                                                              (in domain , error)', ABORTING! Logfile: 'C:\Users\muevo\AppData\Roaming/Godot/mono/mono_logs/2021-05-31_17.08.21_3516.log'.                                                                                                                      At: modules\mono\mono_gd\gd_mono_log.cpp:93      

Minimal reproduction project: CSharpCrash.zip

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 20 (8 by maintainers)

Most upvoted comments

Just rechecked. I was silly enough to assume it was running fine since I got no crash, but it seems I had something wrong in my setup, because the C# function was not being called at all (with an error in the console window).

Now, if it happens on 3.2 as well, I’d say it’s more related to Mono integration than core threading, so I think it’s out of the scope I could deal with properly.

The docs must be updated indeed, I’ve added it to my list this month. But further improvements to the build system in this regard are unlikely though, as with the expected switch to .NET 6 in Godot 4.1 we won’t be building Mono ourselves anymore (and the patches won’t be necessary either with the switch to AssemblyLoadContext), so I prefer not to waste much time there other than fixing the docs.

Maybe the existing documentation on build Godot with Mono support needs to be improved? Especially if users must use our patched Mono builds and not upstream Mono distributions.