Could not load .NET Core dbgshim library when launching debugger

Is there anything I can do to help with this one ?

Wasn’t this solved by the newer .NET Core runtime?

If not, no idea, the only reason would expect LoadLibrary to fail is a broken dylib (ore related missing dependencies maybe). i.e. probably abad install of .NET Core. :frowning:


Would dotnet be using it as well ?

No, it’s only used for debugging.

So it fails the same for .NET Core 5?

I meant if I debug from visual studio code.

Yes it fails for .net core 5 as well.

I would assume it uses it, yeah, but I can’t be sure…

Hmm, damn. I’ll see if I can add more logging or if there’s some error code I can check if LoadLibrary (or rather the UNIX versos of it that it maps) sets iff it returns 0… I’ll do that first thing tomorrow and get you a new build if I find anything I can add.

1 Like

Started a new build now (20200419-124342-elements-develop [setups]) that should try to get the error from dlopen() and show it as apr too the message; hopefully that gives us some idea here to look next.

1 Like

I just installed the latest zip from that. Do I need anything else ?

Where would I be seeing a message ?

Also where does IntPtr.Zero come from ? Can I do a cocoa console app like this ?

  var handle := dlopen('/usr/local/share/dotnet/shared/Microsoft.NETCore.App/5.0.0-preview.2.20160.6/libdbgshim.dylib', RTLD_LAZY);
  if (handle = IntPtr.Zero) then
    var value := dlerror();        

Appended to the message you got before:

        RemObjects.Mono.Helpers.PlatformType.Mac: begin
            result := OSX_dlopen(s, RTLD_NOW or RTLD_FIRST);
            if result = IntPtr.Zero then
              raise new Exception($"Could not load .the NET Core dbgshim library at {s}. Error: {OSX_dlerror()}");

That’s .NET. The debug engine is managed code.

Yes, use RTLD_NOW though, not lazy; thats what we use

I still see

~> Process SailingLogSelfHostedNancy.Core started
~> The process failed to start with the following error: Could not load .the NET Core dbgshim library at /usr/local/share/dotnet/shared/Microsoft.NETCore.App/5.0.0-preview.2.20160.6/libdbgshim.dylib

Ah duh, this is in Fire, so you need a new Fire build, not just an external compiler :frowning:

Workaround: copy the Elements binaries (.dlls and Debugger.exe) into and see if you can still run Fire w/o macOS giving you grief about its signature being broken…

I get this now. I copied the files, I guess Ive broken something ?

~> Process AzureServiceBusWebApplication started

    Native Crash Reporting

Got a abrt while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.

Native stacktrace:

    0x101cf9952 - /Applications/ : mono_dump_native_crash_info
    0x101c95a65 - /Applications/ : mono_handle_native_crash
    0x101cf8f5f - /Applications/ : sigabrt_signal_handler
    0x7fff73a495fd - /usr/lib/system/libsystem_platform.dylib : _sigtramp
    0x7fff73a0bd8b - /usr/lib/system/libsystem_malloc.dylib : free_tiny
    0x7fff7391b808 - /usr/lib/system/libsystem_c.dylib : abort
    0x7fff73a1550b - /usr/lib/system/libsystem_malloc.dylib : has_default_zone0
    0x7fff73a1840f - /usr/lib/system/libsystem_malloc.dylib : malloc_report
    0x1068aa737 - Unknown
    0x1074f31b3 - Unknown
    0x10429ece1 - /Applications/ : System_Threading_Tasks_Task_InnerInvoke
    0x10429ec6c - /Applications/ : System_Threading_Tasks_Task_ExecutionContextCallback_object
    0x10426d023 - /Applications/ : System_Threading_ExecutionContext_Run_System_Threading_ExecutionContext_System_Threading_ContextCallback_object_bool
    0x10429ebad - /Applications/ : System_Threading_Tasks_Task_ExecuteEntry_bool
    0x10427564d - /Applications/ : System_Threading__ThreadPoolWaitCallback_PerformWaitCallback
    0x101bf7944 - /Applications/ : mono_jit_runtime_invoke
    0x101dfdb8f - /Applications/ : mono_runtime_try_invoke
    0x101e2a023 - /Applications/ : worker_callback
    0x101d5f03f - /Applications/ : worker_thread
    0x101e27383 - /Applications/ : start_wrapper_internal
    0x101e271ce - /Applications/ : start_wrapper
    0x7fff73a55109 - /usr/lib/system/libsystem_pthread.dylib : _pthread_start
    0x7fff73a50b8b - /usr/lib/system/libsystem_pthread.dylib : thread_start

Telemetry Dumper:

Pkilling 0x123145353383936x from 0x123145367650304x
Pkilling 0x4358114752x from 0x123145367650304x
Pkilling 0x123145357103104x from 0x123145367650304x
Could not exec mono-hang-watchdog, expected on path ‘/Applications/…/etc/…/bin/mono-hang-watchdog’ (errno 2)
Pkilling 0x123145373978624x from 0x123145367650304x
Pkilling 0x123145371869184x from 0x123145367650304x
Pkilling 0x123145369759744x from 0x123145367650304x
Pkilling 0x123145365540864x from 0x123145367650304x
Pkilling 0x123145363431424x from 0x123145367650304x
Pkilling 0x123145361321984x from 0x123145367650304x
Pkilling 0x123145359212544x from 0x123145367650304x
Entering thread summarizer pause from 0x123145367650304x
Finished thread summarizer pause from 0x123145367650304x.

Waiting for dumping threads to resume

Basic Fault Address Reporting

Memory around native instruction pointer (0x7fff7399433a):0x7fff7399432a ff ff c3 90 90 90 b8 48 01 00 02 49 89 ca 0f 05 …H…I…
0x7fff7399433a 73 08 48 89 c7 e9 e5 a2 ff ff c3 90 90 90 b8 53 s.H…S
0x7fff7399434a 00 00 02 49 89 ca 0f 05 73 08 48 89 c7 e9 cd a2 …I…s.H…
0x7fff7399435a ff ff c3 90 90 90 b8 83 01 00 02 49 89 ca 0f 05 …I…

Managed Stacktrace:

      at <unknown> <0xffffffff>
      at System.Object:__icall_wrapper_mono_marshal_free <0x00056>
      at RemObjects.Oxygene.CoreDebugEngine.CLR.DotNetCorUtilities:OSX_dlerror <0x000ea>
      at RemObjects.Oxygene.CoreDebugEngine.CLR.DotNetCorUtilities:LoadLibrary <0x001b2>
      at RemObjects.Oxygene.CoreDebugEngine.CLR.DotNetCorUtilities:GetInfo <0x00162>
      at <>c__DisplayClass0:<LaunchProcess>b__0 <0x000b2>
      at System.Threading.Tasks.Task:InnerInvoke <0x00060>
      at System.Threading.Tasks.Task:Execute <0x00037>
      at System.Threading.Tasks.Task:ExecutionContextCallback <0x0005b>
      at System.Threading.ExecutionContext:RunInternal <0x00191>
      at System.Threading.ExecutionContext:Run <0x00042>
      at System.Threading.Tasks.Task:ExecuteWithThreadLocal <0x000f6>
      at System.Threading.Tasks.Task:ExecuteEntry <0x000dc>
      at System.Threading.Tasks.Task:System.Threading.IThreadPoolWorkItem.ExecuteWorkItem <0x00026>
      at System.Threading.ThreadPoolWorkQueue:Dispatch <0x00279>
      at System.Threading._ThreadPoolWaitCallback:PerformWaitCallback <0x0001c>
      at <Module>:runtime_invoke_bool <0x0007d>


~> The process failed to start with the following error: Debugger terminated

Hmm, looks like to doesn’t like calling dlerror() from managed :(.

Did your console test app give any results?

I dont think so. I did this

  var handle := dlopen('/usr/local/share/dotnet/shared/Microsoft.NETCore.App/5.0.0-preview.2.20160.6/libdbgshim.dylib', RTLD_NOW);
  var value := dlerror();

and error was nil.
How do I test that handle is valid ?

check if its nil?

I fixed the marshaling a bit and started a new build.

It loads ok. Maybe it only has a problem when it’s managed. What would a dotnet version look like ?

    class method LoadLibrary(s: String): IntPtr;
      case RemObjects.Mono.Helpers.PlatformSupport.Platform of
        RemObjects.Mono.Helpers.PlatformType.Mac: begin
            result := OSX_dlopen(s, RTLD_NOW or RTLD_FIRST);
            if result = IntPtr.Zero then
              raise new Exception($"Could not load .the NET Core dbgshim library at {s}. Error: {Marshal.PtrToStringAuto(OSX_dlerror())}");

    const RTLD_NOW = 2;
    const RTLD_FIRST = 256;

    [DllImport("libdl.dylib", EntryPoint := 'dlopen')]
    class method OSX_dlopen(s: String; flags: Integer): IntPtr; external;
    [DllImport("libdl.dylib", EntryPoint := 'dlclose')]
    class method OSX_dlclose(p: IntPtr): Boolean;external;
    [DllImport("libdl.dylib", EntryPoint := 'dlsym')]
    class method OSX_dlsym(aFlags: IntPtr; s: String): IntPtr;external;
    [DllImport("libdl.dylib", EntryPoint := 'dlerror')]
    class method OSX_dlerror(): IntPtr; external;

New build is done.

Are you also doing a Fire build ?