Bug 21040 - ERR_UNLOADED while debugging assembly in loaded AppDomain
Summary: ERR_UNLOADED while debugging assembly in loaded AppDomain
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Debugger ()
Version: unspecified
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Jeffrey Stedfast
URL:
Depends on:
Blocks:
 
Reported: 2014-07-02 08:56 UTC by Adam Rzepka
Modified: 2015-01-07 01:17 UTC (History)
6 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 Developer Community or GitHub 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 Adam Rzepka 2014-07-02 08:56:12 UTC
I believe that https://bugzilla.xamarin.com/show_bug.cgi?id=18100 is not the same bug, because of different stack and steps to reproduce.

Steps:
1. Create simple app "tester.exe":
    
    class MainClass
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Set breakpoint here");
        }
    }

2. Create second app, which will load and execute the first one a few times:

    class MainClass
    {
        public static void Main(string[] args)
        {
            for (int i = 0; i < 10; ++i)
            {
                AppDomain domain = AppDomain.CreateDomain("tester.exe");
                domain.ExecuteAssembly("tester.exe");
                AppDomain.Unload(domain);
            }
        }
    }

3. In XamarinStudio set breakpoint in first app and start debugging.
4. Hit breakpoint two times, then watch the error occuring:
  Mono.Debugger.Soft.CommandException: Debuggee returned error code ERR_UNLOADED.
   at Mono.Debugger.Soft.VirtualMachine.ErrorHandler(Object sender, ErrorHandlerEventArgs args)
   at Mono.Debugger.Soft.Connection.SendReceive(CommandSet command_set, Int32 command, PacketWriter packet)
   at Mono.Debugger.Soft.Connection.Domain_GetAssemblies(Int64 id)
   at Mono.Debugger.Soft.AppDomainMirror.GetAssemblies()
   at Mono.Debugging.Soft.SoftDebuggerAdaptor.GetType(EvaluationContext ctx, String name, Object[] typeArgs)
   at Mono.Debugging.Evaluation.ObjectValueAdaptor.GetType(EvaluationContext ctx, String name)
   at Mono.Debugging.Soft.SoftDebuggerBacktrace.CreateStackFrame(StackFrame frame, Int32 frameIndex)
   at Mono.Debugging.Soft.SoftDebuggerBacktrace.GetStackFrames(Int32 firstIndex, Int32 lastIndex)
   at Mono.Debugging.Client.Backtrace.GetFrame(Int32 n)
   at Mono.Debugging.Client.Backtrace..ctor(IBacktrace serverBacktrace)
   at Mono.Debugging.Soft.SoftDebuggerSession.GetThreadBacktrace(ThreadMirror thread)
   at Mono.Debugging.Soft.SoftDebuggerSession.HandleBreakEventSet(Event[] es, Boolean dequeuing)
   at Mono.Debugging.Soft.SoftDebuggerSession.HandleEventSet(EventSet es)
   at Mono.Debugging.Soft.SoftDebuggerSession.EventHandler()
5. Debugger and mono stuck.
Comment 1 Zoltan Varga 2014-07-02 09:02:17 UTC
This is probably a dup of:
https://bugzilla.xamarin.com/show_bug.cgi?id=19922
Comment 2 Adam Rzepka 2014-07-02 09:23:42 UTC
Unfortunately, fix for https://bugzilla.xamarin.com/show_bug.cgi?id=19922 didn't help. After f29c547b659c03126989622302dd664e0a29983f error still occurs.
Comment 3 Zoltan Varga 2014-07-03 15:22:56 UTC
I can reproduce this with XS 5.1 (build 462).
This looks like an xs problem, it is calling GetAssemblies () on an AppDomainMirror whose domain has been unloaded.
Comment 4 Ram Chandra 2014-10-30 14:35:29 UTC
Zoltan is able to reproduce this issue. As per comment 3, I am changing it's status from new to confirm.
Comment 5 David Karlaš 2015-01-07 01:17:15 UTC
Changes were made recently in domains handling for debugger. I was able to reproduce this in stable but not in master 5.8.0.156+. Hence marking as resolved fixed.