Description
The original issue is mono/mono#21032 Adding a copy here to make sure we do this work for .NET 6, too. The assembly loading algorithm is different, but the same situation is possible
Sample stack trace from VS Mac https://gist.github.com/Therzok/df71c056b0dabc8a2f3ffb6f1c264488
Thread 8 calls mono_class_create_from_typedef
which then needs to get the parent type and calls mono_class_get_checked
... etc... until we need to load an assembly, and when we can't find it, we call the managed assembly resolver event from mono_domain_assembly_postload_search
.
The managed code tries to lock some managed data structure, but the monitor is already locked, so it waits.
Meanwhile other threads that want to do any type creation are deadlocked because they can't take the loader lock.