You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[macOS] Hosting CoreCLR inside an LLDB plugin fails to initialize the runtime #99977
SOS is an LLDB plugin that is hosts a CoreCLR runtime. It have been failing to work on recent versions of macOS / Xcode, and in Sonoma macOS 14.4 loading the plugin actually kills the LLDB process entirely (see dotnet/diagnostics#4551)
I have only tried on osx-arm64. SIP is not disabled
$ lldb -b -o "plugin load ./out/libhihost.dylib"(lldb) plugin load ./out/libhihost.dylibHello from Chostfxr path is /Users/alklig/work/hihost/out/libhostfxr.dylibrunning with dotnet root /Users/alklig/work/hihost/out/coreclr initializedzsh: killed lldb -b -o "plugin load ./out/libhihost.dylib"
The above happens with macOS Sonoma 14.4. With 14.3, you get a bit further, but the runtime will still fail to initialize.
In dotnet/diagnostics#4551 we found a workaround to at least get past the whole LLDB process aborting, by passing PAL_MachExceptionMode=7
$ PAL_MachExceptionMode=7 lldb -b -o "plugin load ./out/libhihost.dylib"(lldb) plugin load ./out/libhihost.dylibHello from Chostfxr path is /Users/alklig/work/hihost/out/libhostfxr.dylibrunning with dotnet root /Users/alklig/work/hihost/out/coreclr initializedhost says: Failed to create CoreCLR, HRESULT: 0x8007000Chostfxr_run_app finished
Expected output (compare with a "normal" hardened runtime macOS app):
$ ./out/runmyselfHello from Chostfxr path is /Users/alklig/work/hihost/out/libhostfxr.dylibrunning with dotnet root /Users/alklig/work/hihost/out/coreclr initializedHello from C#hostfxr_run_app finished
This is likely not a hosting issue. See also #99172 - the LLDB environment is sufficiently different that some runtime functionality (for example messing with VM page protections in order to initialize the stack guard cookie) just doesn't succeed.
I can actually see another mode of this issue on my 14.4 (SIP disabled). The same failure GUARD_TYPE_MACH_PORT occurs when we call thread_set_state during hardware exception handling in the plugin in the SEHExceptionThread function. So it seems that with SIP disabled, we can pass the PAL initialization, but we crash there. In this case, we are injecting exception handler code into the target thread and since the thread belongs to lldb, it kind of makes sense it may have it guarded.
Activity
dotnet-policy-service commentedon Mar 19, 2024
Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov
See info in area-owners.md if you want to be subscribed.
lambdageek commentedon Mar 19, 2024
This is likely not a hosting issue. See also #99172 - the LLDB environment is sufficiently different that some runtime functionality (for example messing with VM page protections in order to initialize the stack guard cookie) just doesn't succeed.
lambdageek commentedon Mar 19, 2024
if you run without the
PAL_MachExceptionModeworkaround,Console.appshows a bit of what went wrong:janvorli commentedon Mar 20, 2024
I can actually see another mode of this issue on my 14.4 (SIP disabled). The same failure
GUARD_TYPE_MACH_PORToccurs when we callthread_set_stateduring hardware exception handling in the plugin in theSEHExceptionThreadfunction. So it seems that with SIP disabled, we can pass the PAL initialization, but we crash there. In this case, we are injecting exception handler code into the target thread and since the thread belongs to lldb, it kind of makes sense it may have it guarded.dotnet-policy-service commentedon Apr 15, 2026
Tagging subscribers to this area: @agocke
See info in area-owners.md if you want to be subscribed.
Align CoreCLR GS cookie protection with NativeAOT (#132925)