Bug 44381 - Debugger crash with domain unloading and VSTU
Summary: Debugger crash with domain unloading and VSTU
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: Debugger (show other bugs)
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Zoltan Varga
URL:
Depends on:
Blocks:
 
Reported: 2016-09-15 18:00 UTC by Jonathan Chambers
Modified: 2016-11-17 19:19 UTC (History)
2 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description Jonathan Chambers 2016-09-15 18:00:55 UTC
Hello,

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.
Comment 1 Zoltan Varga 2016-11-17 19:19:50 UTC
Fixed in master/4.8, we now return an ERR_UNLOADED error in this case when GetAssemblyObject () is called after receiving an AssemblyUnload event.

Note You need to log in before you can comment on or make changes to this bug.