From ccadee54b48bcf932b8d8e69176e2ee56f47886b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Karlas=CC=8C?= Date: Mon, 9 Jan 2017 10:39:09 +0100 Subject: [PATCH] =?UTF-8?q?Bug=2050464=20-=20Running=20xunit.runner.consol?= =?UTF-8?q?e.exe=20on=20xunit.net=20test=20DLL=20from=20Xamarin=20Studio?= =?UTF-8?q?=20as=20a=20Default=20Run=20Configuration=20causes=20exception?= =?UTF-8?q?=20In=20theory=20at=20time=20of=20AssemblyUnloadEvent=20excepti?= =?UTF-8?q?on=20ERR=5FUNLOADED=20when=20fetching=20Location=20should=20nev?= =?UTF-8?q?er=20happen=20since=20we=20fetched=20and=20cached=20location=20?= =?UTF-8?q?value=20at=20time=20of=20AssemblyLoadEvent.=20But=20since=20the?= =?UTF-8?q?re=20is=20bug=20in=20runtime=20which=20sometimes=20doesn?= =?UTF-8?q?=E2=80=99t=20sent=20AssemblyLoad=20event,=20we=20can=20get=20ex?= =?UTF-8?q?ception=E2=80=A6=20Since=20we=20never=20received=20assembly=20i?= =?UTF-8?q?t=E2=80=99s=20reasonable=20to=20assume=20source=5Fto=5Ftype=20d?= =?UTF-8?q?oesn=E2=80=99t=20have=20type=20of=20that=20assembly,=20hence=20?= =?UTF-8?q?it=20doesn=E2=80=99t=20need=20remove.=20For=20Unloaded=20assemb?= =?UTF-8?q?ly=20message,=20it=E2=80=99s=20better=20to=20say=20=E2=80=9C=E2=80=9D=20then=20crash.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Mono.Debugging.Soft/SoftDebuggerSession.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Mono.Debugging.Soft/SoftDebuggerSession.cs b/Mono.Debugging.Soft/SoftDebuggerSession.cs index d7ae113e6..2a53fce62 100644 --- a/Mono.Debugging.Soft/SoftDebuggerSession.cs +++ b/Mono.Debugging.Soft/SoftDebuggerSession.cs @@ -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) @@ -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 ?? "")); } void HandleVMStartEvents (VMStartEvent[] events)