I am hitting a crash with a recent master based branch debugging Unity embedded Mono with Visual Studio Tools for Unity.
1. During domain unload the debugger agent processes a `EVENT_KIND_ASSEMBLY_UNLOAD` event for an assembly being unloaded (was only in the unloaded domain). Note at this point the domain is already unloaded, most importantly the domain vtable cache on each MonoClass has been cleared for this domain.
2. The debugger agent thread gets a `CMD_ASSEMBLY_GET_OBJECT` command from VSTU. This calls `mono_assembly_get_object_checked` which attempts to construct an object for the assembly, including creating a new vtable from the already unloaded domain using the domain allocator.
3. We create this vtable and cache it in the MonoClass based on the unloaded domain’s id.
4. Domain unloads, domain allocator memory freed, new domain is created with *same id*
5. Attempt to create another assembly object and get a corrupt vtable
I can try to create a repro case independent of Unity/VSTU, but am have not done so currently.
Fixed in master/4.8, we now return an ERR_UNLOADED error in this case when GetAssemblyObject () is called after receiving an AssemblyUnload event.