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 ()
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)

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

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

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.