Skip to content

setclrpath fails with "Runtime required" when debugging live process #5284

Open
@loop-evgeny

Description

@loop-evgeny

Description

I use LLDB to attach to a live .NET process using self-contained deployment, and load SOS:

lldb -o plugin load "/opt/dotnet-sdk/sos/libsosplugin.so" -o sethostruntime "/path/to/my/self-contained/app" -p 1234
...
Executable module set to "/path/to/my/self-contained/app/My.Exe".
Architecture set to: x86_64-pc-linux-gnu.
(lldb) plugin load "/opt/dotnet-sdk/sos/libsosplugin.so"
(lldb) sethostruntime "/path/to/my/self-contained/app"
Using .NET Core runtime (version 0.0) to host the managed SOS code
Host runtime path: /path/to/my/self-contained/app

It appears to work, although the "version 0.0" looks suspicious! Some SOS commands then fail, however:

(lldb) logging on

(lldb) clrstack
 Information: 0 : HostServices.UpdateTarget 1489343 #0
Failed to find runtime module (libcoreclr.so), 0x80004002
Extension commands need it in order to have something to do.
For more information see https://go.microsoft.com/fwlink/?linkid=2135652
ClrStack  failed

(lldb) setclrpath /path/to/my/self-contained/app
 Information: 0 : HostServices.UpdateTarget 1489343 #0
 Error: 0 : System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> Microsoft.Diagnostics.DebugServices.DiagnosticsException: Runtime required
   at Microsoft.Diagnostics.ExtensionCommands.SetClrPath.Invoke()
   at InvokeStub_SetClrPath.Invoke(Object, Object, IntPtr*)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
   --- End of inner exception stack trace ---
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
   at Microsoft.Diagnostics.DebugServices.Implementation.Utilities.Invoke(MethodBase method, Object instance, IServiceProvider provider)
 Error: 0 : Microsoft.Diagnostics.DebugServices.DiagnosticsException: Runtime required
   at Microsoft.Diagnostics.DebugServices.Implementation.Utilities.Invoke(MethodBase method, Object instance, IServiceProvider provider)
   at Microsoft.Diagnostics.DebugServices.Implementation.CommandService.CommandHandler.Invoke(InvocationContext context, IServiceProvider services)
   at Microsoft.Diagnostics.DebugServices.Implementation.CommandService.CommandGroup.Execute(IReadOnlyList`1 commandLine, IServiceProvider services)
   at Microsoft.Diagnostics.DebugServices.Implementation.CommandService.Execute(String commandName, String[] commandLineArray, IServiceProvider services)
   at Microsoft.Diagnostics.DebugServices.Implementation.CommandService.Execute(String commandName, String commandArguments, IServiceProvider services)
   at SOS.Extensions.HostServices.DispatchCommand(IntPtr self, String commandName, String commandArguments, Boolean displayCommandNotFound)
Runtime required
SetClrPath /path/to/my/self-contained/app  failed

(lldb) dumpheap -stat
No CLR runtime found.
This means that a .NET runtime module or the DAC for the runtime can not be found, loaded or downloaded.
For more information see https://go.microsoft.com/fwlink/?linkid=2135652

Configuration

Running on Ubuntu 24.04.2 x64, physical machine, no containerization, lldb version 18.1.3. The .NET app is self-contained, built on an Ubuntu 22.04 machine using .NET SDK 8.0.404.

.NET runtime is not installed globally on the machine running , but .NET SDK 9.0.2 was downloaded to /opt/dotnet-sdk and SOS was installed there using dotnet tool. The same also happens with .NET SDK 8.0.406.

$ /opt/dotnet-sdk/dotnet --info
.NET SDK:
 Version:           9.0.200
 Commit:            90e8b202f2
 Workload version:  9.0.200-manifests.b4a8049f
 MSBuild version:   17.13.8+cbc39bea8

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  24.04
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /opt/dotnet-sdk/sdk/9.0.200/

.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.2
  Architecture: x64
  Commit:       80aa709f5d

.NET SDKs installed:
  9.0.200 [/opt/dotnet-sdk/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 9.0.2 [/opt/dotnet-sdk/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 9.0.2 [/opt/dotnet-sdk/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found
(lldb) sosstatus
Target OS: LINUX Architecture: X64 ProcessId: 1489343 (0x16B9BF)
SpecialDiagInfoHeader   : 00007FFFFFF10000 <NONE>
Current symbol store settings:
-> Cache: /home/engine/.dotnet/symbolcache
-> Server: https://msdl.microsoft.com/download/symbols/ Timeout: 4 RetryCount: 0
Extensions loaded:
-> 9.0.607501+a651406e39038aef1dbc7c8097b52953284dba27 /opt/dotnet-sdk/sos/Microsoft.Diagnostics.ExtensionCommands.dll
GC memory usage for managed SOS components: 1,425,648 bytes

Regression?

Worked on Ubuntu 22.04 with .NET 8 SDK, at least.

Other information

The only relevant issue I could find was #3222, but that was about a core dump, not a live process. I have checked that libcoreclr.so is loaded in my case:

(lldb) target modules list
...
[ 11] 0B59EBA9-A939-C7A4-3478-E9281698F809-55E58D4C 0x000077b711c00000 /path/to/my/self-contained/app/libcoreclr.so 
...

The app directory also contains libmscordaccore.so.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions