Skip to content

Commit

Permalink
Bug 50464 - Running xunit.runner.console.exe on xunit.net test DLL fr…
Browse files Browse the repository at this point in the history
…om Xamarin Studio as a Default Run Configuration causes exception

In theory at time of AssemblyUnloadEvent exception ERR_UNLOADED when fetching Location should never happen since we fetched and cached location value at time of AssemblyLoadEvent. But since there is bug in runtime which sometimes doesn’t sent AssemblyLoad event, we can get exception… Since we never received assembly it’s reasonable to assume source_to_type doesn’t have type of that assembly, hence it doesn’t need remove. For Unloaded assembly message, it’s better to say “<unknown>” then crash.
  • Loading branch information
David Karlaš committed Jan 9, 2017
1 parent 3051621 commit ccadee5
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions Mono.Debugging.Soft/SoftDebuggerSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1920,7 +1920,16 @@ void HandleAssemblyUnloadEvents (AssemblyUnloadEvent[] events)
var asm = events [0].Assembly;
if (events.Length > 1 && events.Any (a => a.Assembly != asm))
throw new InvalidOperationException ("Simultaneous AssemblyUnloadEvents for multiple assemblies");


string assemblyLocation;
try {
assemblyLocation = asm.Location;
} catch (CommandException ex) {
if (ex.ErrorCode != ErrorCode.ERR_UNLOADED)
throw ex;
assemblyLocation = null;
}

if (assemblyFilters != null) {
int index = assemblyFilters.IndexOf (asm);
if (index != -1)
Expand Down Expand Up @@ -1962,10 +1971,12 @@ void HandleAssemblyUnloadEvents (AssemblyUnloadEvent[] events)
}
}

foreach (var pair in source_to_type) {
pair.Value.RemoveAll (m => PathComparer.Equals (m.Assembly.Location, asm.Location));
if (assemblyLocation != null) {
foreach (var pair in source_to_type) {
pair.Value.RemoveAll (m => PathComparer.Equals (m.Assembly.Location, assemblyLocation));
}
}
OnDebuggerOutput (false, string.Format ("Unloaded assembly: {0}\n", asm.Location));
OnDebuggerOutput (false, string.Format ("Unloaded assembly: {0}\n", assemblyLocation ?? "<unknown>"));
}

void HandleVMStartEvents (VMStartEvent[] events)
Expand Down

0 comments on commit ccadee5

Please sign in to comment.