Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libsosplugin.dylib: CoreCLR host crash on macOS Sonoma 14.4 on arm64 #4551

Open
lambdageek opened this issue Mar 12, 2024 · 10 comments
Open
Assignees
Labels
Milestone

Comments

@lambdageek
Copy link
Member

Description

After installing dotnet-sos and adding then installing the plugin using dotnet-sos install, I get a crash as soon as the plugin
tries to initialize the coreclr host.

Note this is different from #4259 where the coreclr host fails to initialize but at least it doesn't kill the lldb session.

The new behavior is that lldb completely dies. Looking in Console.app, I see the following stack trace:

Note CorUnix::CPalThread::EnableMachExceptions() crashing in a call to thread_swap_exception_ports due to an EXC_GUARD GUARD_TYPE_MACH_PORT mach exception. Looking around it seems like (see this StackOverflow answer) this is because the exception port for the LLDB process is guarded now. Possibly this is new in macOS 14.4.

Translated Report (Full Report Below)
-------------------------------------

Process:               lldb [5222]
Path:                  /Applications/Xcode-15.3.0.app/Contents/Developer/usr/bin/lldb
Identifier:            lldb
Version:               ???
Code Type:             ARM-64 (Native)
Parent Process:        zsh [815]
Responsible:           iTerm2 [713]
User ID:               501

Date/Time:             2024-03-12 18:51:38.3927 -0400
OS Version:            macOS 14.4 (23E214)
Report Version:        12
Anonymous UUID:        1143D3D0-7711-BC35-8E10-8642D5EAA935


Time Awake Since Boot: 740 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_GUARD (SIGKILL)
Exception Codes:       GUARD_TYPE_MACH_PORT
Exception Codes:       0x00000000000f4f10, 0x0000000000000000

Termination Reason:    Namespace GUARD, Code 2305843036968406800 

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	       0x1971fa1f4 mach_msg2_trap + 8
1   libsystem_kernel.dylib        	       0x19720cb24 mach_msg2_internal + 80
2   libsystem_kernel.dylib        	       0x197229db0 thread_swap_exception_ports + 368
3   libcoreclr.dylib              	       0x10786bad8 CorUnix::CPalThread::EnableMachExceptions() + 108
4   libcoreclr.dylib              	       0x10786a7f8 CorUnix::CreateThreadData(CorUnix::CPalThread**) + 260
5   libcoreclr.dylib              	       0x107840c34 Initialize(int, char const* const*, unsigned int) + 1320
6   libcoreclr.dylib              	       0x107841004 PAL_InitializeCoreCLR + 60
7   libcoreclr.dylib              	       0x10786e894 coreclr_initialize + 408
8   libsosplugin.dylib            	       0x101e518e4 InitializeNetCoreHost() + 2492
9   libsosplugin.dylib            	       0x101e50ee0 InitializeHosting() + 36
10  libsosplugin.dylib            	       0x101e468f4 PluginExtensions::GetHost() + 40
11  libsosplugin.dylib            	       0x101e52b94 Extensions::GetHostServices() + 56
12  libsosplugin.dylib            	       0x101e503a4 LLDBServices::ExecuteCommand(char const*, char**, lldb::SBCommandReturnObject&) + 112
13  libsosplugin.dylib            	       0x101e481f0 sosCommand::DoExecute(lldb::SBDebugger, char**, lldb::SBCommandReturnObject&) + 100
14  LLDB                          	       0x1140ec630 lldb_private::CommandPluginInterfaceImplementation::DoExecute(lldb_private::Args&, lldb_private::CommandReturnObject&) + 268
15  LLDB                          	       0x1143a0de4 lldb_private::CommandObjectParsed::Execute(char const*, lldb_private::CommandReturnObject&) + 660
16  LLDB                          	       0x114397734 lldb_private::CommandInterpreter::HandleCommand(char const*, lldb_private::LazyBool, lldb_private::CommandReturnObject&, bool) + 2172
17  LLDB                          	       0x11439b0d4 lldb_private::CommandInterpreter::IOHandlerInputComplete(lldb_private::IOHandler&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&) + 828
18  LLDB                          	       0x1142d07a4 lldb_private::IOHandlerEditline::Run() + 304
19  LLDB                          	       0x1142b3fe0 lldb_private::Debugger::RunIOHandlers() + 140
20  LLDB                          	       0x11439c320 lldb_private::CommandInterpreter::RunCommandInterpreter(lldb_private::CommandInterpreterRunOptions&) + 196
21  LLDB                          	       0x114105070 lldb::SBDebugger::RunCommandInterpreter(bool, bool) + 124
22  lldb                          	       0x100dfbbd0 Driver::MainLoop() + 3312
23  lldb                          	       0x100dfc634 main + 2040
24  dyld                          	       0x196eb20e0 start + 2360

Thread 1:
0   libsystem_kernel.dylib        	       0x1971fa1f4 mach_msg2_trap + 8
1   libsystem_kernel.dylib        	       0x19720cb24 mach_msg2_internal + 80
2   libsystem_kernel.dylib        	       0x197202e34 mach_msg_overwrite + 476
3   libsystem_kernel.dylib        	       0x1971fa578 mach_msg + 24
4   CoreFoundation                	       0x19731a058 __CFRunLoopServiceMachPort + 160
5   CoreFoundation                	       0x19731891c __CFRunLoopRun + 1208
6   CoreFoundation                	       0x197317e0c CFRunLoopRunSpecific + 608
7   CoreFoundation                	       0x197395e3c CFRunLoopRun + 64
8   DebugSymbols                  	       0x1ad27bac8 SpotlightQueryThread(void*) + 580
9   libsystem_pthread.dylib       	       0x19723af94 _pthread_start + 136
10  libsystem_pthread.dylib       	       0x197235d34 thread_start + 8

Thread 2:
0   libsystem_pthread.dylib       	       0x197235d20 start_wqthread + 0

Thread 3:
0   libsystem_pthread.dylib       	       0x197235d20 start_wqthread + 0

Thread 4:: lldb.debugger.event-handler
0   libsystem_kernel.dylib        	       0x1971fd9ec __psynch_cvwait + 8
1   libsystem_pthread.dylib       	       0x19723b55c _pthread_cond_wait + 1228
2   libc++.1.dylib                	       0x197160b14 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
3   LLDB                          	       0x1144cc364 lldb_private::Listener::GetEventInternal(lldb_private::Timeout<std::__1::ratio<1l, 1000000l>> const&, lldb_private::Broadcaster*, lldb_private::ConstString const*, unsigned int, unsigned int, std::__1::shared_ptr<lldb_private::Event>&) + 488
4   LLDB                          	       0x1142b75f8 lldb_private::Debugger::DefaultEventHandler() + 276
5   LLDB                          	       0x1142b9910 std::__1::__function::__func<lldb_private::Debugger::StartEventHandlerThread()::$_3, std::__1::allocator<lldb_private::Debugger::StartEventHandlerThread()::$_3>, void* ()>::operator()() + 16
6   LLDB                          	       0x114370938 lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*) + 108
7   LLDB                          	       0x1183ac3a8 lldb_private::HostThreadMacOSX::ThreadCreateTrampoline(void*) + 32
8   libsystem_pthread.dylib       	       0x19723af94 _pthread_start + 136
9   libsystem_pthread.dylib       	       0x197235d34 thread_start + 8

Thread 5:: <lldb.process.gdb-remote.async>
0   libsystem_kernel.dylib        	       0x1971fd9ec __psynch_cvwait + 8
1   libsystem_pthread.dylib       	       0x19723b55c _pthread_cond_wait + 1228
2   libc++.1.dylib                	       0x197160b14 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
3   LLDB                          	       0x1144cc364 lldb_private::Listener::GetEventInternal(lldb_private::Timeout<std::__1::ratio<1l, 1000000l>> const&, lldb_private::Broadcaster*, lldb_private::ConstString const*, unsigned int, unsigned int, std::__1::shared_ptr<lldb_private::Event>&) + 488
4   LLDB                          	       0x11476daa0 lldb_private::process_gdb_remote::ProcessGDBRemote::AsyncThread() + 292
5   LLDB                          	       0x114776f80 std::__1::__function::__func<lldb_private::process_gdb_remote::ProcessGDBRemote::StartAsyncThread()::$_7, std::__1::allocator<lldb_private::process_gdb_remote::ProcessGDBRemote::StartAsyncThread()::$_7>, void* ()>::operator()() + 16
6   LLDB                          	       0x114370938 lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*) + 108
7   LLDB                          	       0x1183ac3a8 lldb_private::HostThreadMacOSX::ThreadCreateTrampoline(void*) + 32
8   libsystem_pthread.dylib       	       0x19723af94 _pthread_start + 136
9   libsystem_pthread.dylib       	       0x197235d34 thread_start + 8

Thread 6:: <lldb.process.internal-state(pid=5225)>
0   libsystem_kernel.dylib        	       0x1971fd9ec __psynch_cvwait + 8
1   libsystem_pthread.dylib       	       0x19723b55c _pthread_cond_wait + 1228
2   libc++.1.dylib                	       0x197160b14 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
3   LLDB                          	       0x1144cc364 lldb_private::Listener::GetEventInternal(lldb_private::Timeout<std::__1::ratio<1l, 1000000l>> const&, lldb_private::Broadcaster*, lldb_private::ConstString const*, unsigned int, unsigned int, std::__1::shared_ptr<lldb_private::Event>&) + 488
4   LLDB                          	       0x114437ba0 lldb_private::Process::GetEventsPrivate(std::__1::shared_ptr<lldb_private::Event>&, lldb_private::Timeout<std::__1::ratio<1l, 1000000l>> const&, bool) + 196
5   LLDB                          	       0x11444100c lldb_private::Process::RunPrivateStateThread(bool) + 228
6   LLDB                          	       0x1144496bc std::__1::__function::__func<lldb_private::Process::StartPrivateStateThread(bool)::$_6, std::__1::allocator<lldb_private::Process::StartPrivateStateThread(bool)::$_6>, void* ()>::operator()() + 24
7   LLDB                          	       0x114370938 lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*) + 108
8   LLDB                          	       0x1183ac3a8 lldb_private::HostThreadMacOSX::ThreadCreateTrampoline(void*) + 32
9   libsystem_pthread.dylib       	       0x19723af94 _pthread_start + 136
10  libsystem_pthread.dylib       	       0x197235d34 thread_start + 8

Thread 7:: <lldb.comm.process.stdio>
0   libsystem_kernel.dylib        	       0x197205358 __select + 8
1   LLDB                          	       0x1144d7790 SelectHelper::Select() + 1292
2   LLDB                          	       0x114383568 lldb_private::ConnectionFileDescriptor::BytesAvailable(lldb_private::Timeout<std::__1::ratio<1l, 1000000l>> const&, lldb_private::Status*) + 392
3   LLDB                          	       0x11438319c lldb_private::ConnectionFileDescriptor::Read(void*, unsigned long, lldb_private::Timeout<std::__1::ratio<1l, 1000000l>> const&, lldb::ConnectionStatus&, lldb_private::Status*) + 148
4   LLDB                          	       0x1142ae214 lldb_private::Communication::ReadFromConnection(void*, unsigned long, lldb_private::Timeout<std::__1::ratio<1l, 1000000l>> const&, lldb::ConnectionStatus&, lldb_private::Status*) + 68
5   LLDB                          	       0x1143121e0 lldb_private::ThreadedCommunication::ReadThread() + 604
6   LLDB                          	       0x114312764 std::__1::__function::__func<lldb_private::ThreadedCommunication::StartReadThread(lldb_private::Status*)::$_0, std::__1::allocator<lldb_private::ThreadedCommunication::StartReadThread(lldb_private::Status*)::$_0>, void* ()>::operator()() + 16
7   LLDB                          	       0x114370938 lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*) + 108
8   LLDB                          	       0x1183ac3a8 lldb_private::HostThreadMacOSX::ThreadCreateTrampoline(void*) + 32
9   libsystem_pthread.dylib       	       0x19723af94 _pthread_start + 136
10  libsystem_pthread.dylib       	       0x197235d34 thread_start + 8

Thread 8:
0   libsystem_kernel.dylib        	       0x1971fa1f4 mach_msg2_trap + 8
1   libsystem_kernel.dylib        	       0x19720cb24 mach_msg2_internal + 80
2   libsystem_kernel.dylib        	       0x197202e34 mach_msg_overwrite + 476
3   libsystem_kernel.dylib        	       0x1971fa578 mach_msg + 24
4   libcoreclr.dylib              	       0x10786cbe4 MachMessage::Receive(unsigned int) + 80
5   libcoreclr.dylib              	       0x10786bf64 SEHExceptionThread(void*) + 144
6   libsystem_pthread.dylib       	       0x19723af94 _pthread_start + 136
7   libsystem_pthread.dylib       	       0x197235d34 thread_start + 8


Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x0000000200000003   x2: 0x0000003c80001513   x3: 0x0000070700000103
    x4: 0x00000e1f00000000   x5: 0x0000070700000001   x6: 0x0000000000000330   x7: 0x0000000000000000
    x8: 0xfffffffffffffbbf   x9: 0x000000014101ebe4  x10: 0x000000000000007e  x11: 0x0000000000000074
   x12: 0x000000000000004c  x13: 0x00000000001ff800  x14: 0x00000000000007fb  x15: 0x00000000d15eb82a
   x16: 0xffffffffffffffd1  x17: 0x00000002092b2cb8  x18: 0x0000000000000000  x19: 0x0000000000000000
   x20: 0x0000000000000330  x21: 0x0000070700000001  x22: 0x00000e1f00000000  x23: 0x0000070700000103
   x24: 0x000000016f009528  x25: 0x0000003c80001513  x26: 0x0000000200000003  x27: 0x0000000200000003
   x28: 0x000000016f009f18   fp: 0x000000016f009510   lr: 0x000000019720cb24
    sp: 0x000000016f0094c0   pc: 0x00000001971fa1f4 cpsr: 0x40001000
   far: 0x0000000000000000  esr: 0x56000080  Address size fault

Binary Images:
       0x10782c000 -        0x107cfbfff libcoreclr.dylib (*) <95f2d117-c7d1-3084-afb4-d2b5c498a03e> /usr/local/share/dotnet/shared/Microsoft.NETCore.App/6.0.27/libcoreclr.dylib
       0x101e44000 -        0x101e57fff libsosplugin.dylib (*) <bf949d4f-4a6a-3297-9fe4-a60050bffd0c> /Users/USER/*/libsosplugin.dylib
       0x1017ec000 -        0x1017f3fff readline.cpython-39-darwin.so (*) <efea2094-a451-3145-8280-236ee5e3066e> /Applications/Xcode-15.3.0.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/lib-dynload/readline.cpython-39-darwin.so
       0x101630000 -        0x101637fff _heapq.cpython-39-darwin.so (*) <bc118e79-30e0-3825-8459-0b77514d1ab2> /Applications/Xcode-15.3.0.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/lib-dynload/_heapq.cpython-39-darwin.so
       0x10161c000 -        0x10161ffff _uuid.cpython-39-darwin.so (*) <700c96e5-5b9a-328a-bf55-3e85a8e8bf28> /Applications/Xcode-15.3.0.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/lib-dynload/_uuid.cpython-39-darwin.so
       0x1140c0000 -        0x11ab2bfff com.apple.LLDB.framework (1500.0.404.7) <12ed32d3-514a-3acd-94b1-0211b8ab1706> /Applications/Xcode-15.3.0.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB
       0x101820000 -        0x101a7bfff com.apple.python3 (3.9.6) <2bde4717-792d-3b4a-885e-35fc176978b0> /Applications/Xcode-15.3.0.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Python3
       0x1013a8000 -        0x1013cffff libSwiftCompilerPluginMessageHandling.dylib (*) <49f74d5d-fdea-3100-9176-a39f9c27aa1d> /Applications/Xcode-15.3.0.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Libraries/usr/lib/swift/host/libSwiftCompilerPluginMessageHandling.dylib
       0x10133c000 -        0x101363fff libSwiftOperators.dylib (*) <9bcc6724-f47a-3ad3-bb4d-71f81d61fa6b> /Applications/Xcode-15.3.0.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Libraries/usr/lib/swift/host/libSwiftOperators.dylib
       0x101298000 -        0x1012c7fff libSwiftSyntaxMacroExpansion.dylib (*) <49ad50e4-1252-346f-bbe8-e3b61ec4e39d> /Applications/Xcode-15.3.0.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Libraries/usr/lib/swift/host/libSwiftSyntaxMacroExpansion.dylib
       0x101308000 -        0x10130ffff libSwiftSyntaxMacros.dylib (*) <40d2cb33-3a10-341a-b7dd-af4cc3cf4b39> /Applications/Xcode-15.3.0.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Libraries/usr/lib/swift/host/libSwiftSyntaxMacros.dylib
       0x101654000 -        0x1016bffff libSwiftSyntaxBuilder.dylib (*) <9e8fc4a7-02f9-33c9-980e-7c52bb48b6f7> /Applications/Xcode-15.3.0.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Libraries/usr/lib/swift/host/libSwiftSyntaxBuilder.dylib
       0x101434000 -        0x1014dbfff libSwiftParserDiagnostics.dylib (*) <0545846c-763d-3e02-a0f9-7b3db30d347a> /Applications/Xcode-15.3.0.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Libraries/usr/lib/swift/host/libSwiftParserDiagnostics.dylib
       0x1015e8000 -        0x1015fbfff libSwiftBasicFormat.dylib (*) <47b5a35e-cf02-304a-bea2-a521a9d58418> /Applications/Xcode-15.3.0.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Libraries/usr/lib/swift/host/libSwiftBasicFormat.dylib
       0x102450000 -        0x1027affff libSwiftParser.dylib (*) <3bda705b-e114-324a-9282-659188e38f43> /Applications/Xcode-15.3.0.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Libraries/usr/lib/swift/host/libSwiftParser.dylib
       0x101584000 -        0x10159bfff libSwiftDiagnostics.dylib (*) <310c537a-44f9-34d0-89c2-1397499d8f33> /Applications/Xcode-15.3.0.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Libraries/usr/lib/swift/host/libSwiftDiagnostics.dylib
       0x1041b8000 -        0x10451bfff libSwiftSyntax.dylib (*) <00ca8569-f306-3471-9c25-18aec816bff5> /Applications/Xcode-15.3.0.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Libraries/usr/lib/swift/host/libSwiftSyntax.dylib
       0x100df4000 -        0x100e23fff lldb (*) <0d686234-bd8c-3153-af72-4378a55eca95> /Applications/Xcode-15.3.0.app/Contents/Developer/usr/bin/lldb
       0x1971f9000 -        0x197233ffb libsystem_kernel.dylib (*) <1889ce0a-52e7-3122-8907-81af920ac472> /usr/lib/system/libsystem_kernel.dylib
       0x196eac000 -        0x196f349db dyld (*) <8e1e5ee2-f89a-33a7-bb0a-74bdc06b7828> /usr/lib/dyld
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???
       0x19729c000 -        0x197774fff com.apple.CoreFoundation (6.9) <33908a83-098f-3437-973e-fb848c4f39df> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
       0x1ad27a000 -        0x1ad2beff8 com.apple.DebugSymbols (195.1) <bdc626b5-c868-37ba-bfa7-ec6f22191afc> /System/Library/PrivateFrameworks/DebugSymbols.framework/Versions/A/DebugSymbols
       0x197234000 -        0x197240fff libsystem_pthread.dylib (*) <45239f06-cc53-36d0-9933-7776ac7ea2fa> /usr/lib/system/libsystem_pthread.dylib
       0x197150000 -        0x1971dcff7 libc++.1.dylib (*) <08c4329e-407f-310b-b037-75a8020b2963> /usr/lib/libc++.1.dylib

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 1
    thread_create: 0
    thread_set_state: 14

VM Region Summary:
ReadOnly portion of Libraries: Total=816.7M resident=0K(0%) swapped_out_or_unallocated=816.7M(100%)
Writable regions: Total=1.5G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=1.5G(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Activity Tracing                   256K        1 
Kernel Alloc Once                   32K        1 
MALLOC                             1.5G       34 
MALLOC guard page                   96K        6 
STACK GUARD                       56.1M        9 
Stack                             27.2M        9 
VM_ALLOCATE                       8464K       31 
__AUTH                             344K       70 
__AUTH_CONST                      4104K      153 
__DATA                            4603K      172 
__DATA_CONST                      12.2M      172 
__DATA_DIRTY                       365K       58 
__LINKEDIT                       570.8M       19 
__OBJC_RO                         71.7M        1 
__OBJC_RW                         2195K        1 
__TEXT                           245.9M      179 
dyld private memory                272K        1 
mapped file                       41.1M        8 
shared memory                      624K        7 
===========                     =======  ======= 
TOTAL                              2.5G      932 

@lambdageek lambdageek added the bug Something isn't working label Mar 12, 2024
@lambdageek
Copy link
Member Author

/cc @hoyosjs

@mikem8361
Copy link
Member

This looks like a runtime issue not SOS's. CorUnix::CPalThread::EnableMachExceptions()'s call to thread_swap_exception_ports in the runtime's PAL. I'm not sure what SOS can do about it.

@lambdageek
Copy link
Member Author

yea, it's a runtime issue. Just wanted to bring it up here in case anyone else runs into it

@mikem8361
Copy link
Member

I brought it up because there is nothing we can do in the diagnostics repo to fix it that maybe it should be a runtime repo issue.

@rolfbjarne
Copy link
Member

I can reproduce as well.

If I export PAL_MachExceptionMode=7 first, lldb doesn't crash anymore, but libsos doesn't work:

(lldb) plugin load /Users/rolf/.dotnet/sos/libsosplugin.dylib
(lldb) setsymbolserver -ms
Error: Fail to initialize coreclr 80070008

Maybe move this issue to the runtime repo if that's where it should be?

@lambdageek
Copy link
Member Author

@rolfbjarne I was going to open a new issue for dotnet/runtime with just a barebones LLDB plugin that hosts CoreCLR so that it's easier to reproduce. it's still on my todo list - I just need to clean up my repro.

@lambdageek
Copy link
Member Author

Not sure if it's related, but the JVM folks discovered that pthread_write_protect_np(0) sometimes causes macOS Sonoma 14.4 to kill a process when it's trying to access unrelated mmaped memory with a SIGKILL. Previous versions of macOS issued a SIGBUS.

https://bugs.java.com/bugdatabase/view_bug?bug_id=8327860 (see in particular the repro from 12-03-2024, reproduced below:

#include <stdio.h>
#include <sys/mman.h>
#include <pthread.h>

int main() {
  pthread_jit_write_protect_np(0);

  char* mem = (char*)mmap(0, 16 * 1024, 0, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0);
  fprintf(stderr, "addr = %p\n", mem);

  char value = *mem;
  fprintf(stderr, "value = %c\n", value);

  return 0;
}

macOS 14.3: SIGBUS
macOS 14.4: SIGKILL

@lambdageek
Copy link
Member Author

I opened dotnet/runtime#99977 to track potential runtime work. I think it's worthwhile to keep this diagnostics issue open since this is probably where folks will look for SOS issues.

@vvuk
Copy link

vvuk commented Mar 29, 2024

A workaround is to use a non-Apple lldb, i.e. one from homebrew as it won't be as locked down. This doesn't help for debugging from Xcode, but at least can unblock dotnet-sos for those on 14.4. (brew install llvm; /opt/homebrew/Cellar/llvm/*/bin/lldb)

@mikem8361
Copy link
Member

Have you successfully loaded a x64 libsosplugin.dylib under the brew installed lldb? We tried recently and plugin load libsosplugin.dylib failed with error: this file does not represent a loadable dylib.

/cc: @mikelle-rogers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants