LLDB expression causes MacOS app to crash (only when LLDB was attached)
- Dominant language
- C++
- Stars
- 1.3k
- Forks
- 404
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 38
Description
The prerequisite to create/build a ".NET for MacOS" app is to install the MacOS workload (which itself requires Xcode.app to be installed): `dotnet workload install macos`
### Repro steps
```
dotnet new macos
dotnet run
lldb -p $PID_FOR_RUNNING_APP
(lldb) p [NSApplication sharedApplication]
```
### Actual result
The MacOS app crashes, and LLDB gives this output:
```
warning: could not execute support code to read Objective-C class data in the process. This may reduce the quality of type information available.
error: Expression can't be run, because there is no JIT compiled function
```
LLDB output details
```
kylewhite@kywhi-mbp ~/Workspace/blankmacos $ dotnet run
kylewhite@kywhi-mbp ~/Workspace/blankmacos $ lldb -p 4094
Added Microsoft public symbol server
(lldb) process attach --pid 4094
Process 4094 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
frame #0: 0x00007ff80134caba libsystem_kernel.dylib`mach_msg_trap + 10
libsystem_kernel.dylib`mach_msg_trap:
-> 0x7ff80134caba <+10>: retq
0x7ff80134cabb <+11>: nop
libsystem_kernel.dylib`mach_msg_overwrite_trap:
0x7ff80134cabc <+0>: movq %rcx, %r10
0x7ff80134cabf <+3>: movl $0x1000020, %eax ; imm = 0x1000020
Target 0: (blankmacos) stopped.
Executable module set to "/Users/kylewhite/Workspace/blankmacos/bin/Debug/net6.0-macos/osx-x64/blankmacos.app/Contents/MacOS/blankmacos".
Architecture set to: x86_64h-apple-macosx-.
(lldb) p [NSApplication sharedApplication]
warning: could not execute support code to read Objective-C class data in the process. This may reduce the quality of type information available.
error: Expression can't be run, because there is no JIT compiled function
```
Here is the Apple crash report of the crashed app: https://gist.github.com/kdubau/1f7a1612e695f8fc98847cf9dc3630de
### Expected result
It should print the object:
```
(lldb) p [NSApplication sharedApplication]
(NSApplication *) $0 = 0x0000000101306160
```
The problem only happens when LLDB is attached to the process. If you launch the process with LLDB, than it works fine:
```
dotnet new macos
dotnet build
lldb bin/Debug/net6.0-macos/osx-x64/blankmacos.app/Contents/MacOS/blankmacos
(lldb) pro launch
Control+C
(lldb) p [NSApplication sharedApplication]
(NSApplication *) $0 = 0x0000000101f0b220
```
LLDB output details
```
kylewhite@kywhi-mbp ~/Workspace/blankmacos $ lldb bin/Debug/net6.0-macos/osx-x64/blankmacos.app/Contents/MacOS/blankmacos
Added Microsoft public symbol server
(lldb) target create "bin/Debug/net6.0-macos/osx-x64/blankmacos.app/Contents/MacOS/blankmacos"
Current executable set to '/Users/kylewhite/Workspace/blankmacos/bin/Debug/net6.0-macos/osx-x64/blankmacos.app/Contents/MacOS/blankmacos' (x86_64).
(lldb) pro launch
Process 4382 launched: '/Users/kylewhite/Workspace/blankmacos/bin/Debug/net6.0-macos/osx-x64/blankmacos.app/Contents/MacOS/blankmacos' (x86_64)
2022-03-10 15:48:59.999652-0500 blankmacos[4382:4562663] SecTaskLoadEntitlements failed error=22 cs_flags=20, pid=4382
2022-03-10 15:48:59.999816-0500 blankmacos[4382:4562663] SecTaskCopyDebugDescription: blankmacos[4382]/0#-1 LF=0
Process 4382 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
frame #0: 0x00007ff80134caba libsystem_kernel.dylib`mach_msg_trap + 10
libsystem_kernel.dylib`mach_msg_trap:
-> 0x7ff80134caba <+10>: retq
0x7ff80134cabb <+11>: nop
libsystem_kernel.dylib`mach_msg_overwrite_trap:
0x7ff80134cabc <+0>: movq %rcx, %r10
0x7ff80134cabf <+3>: movl $0x1000020, %eax ; imm = 0x1000020
Target 0: (blankmacos) stopped.
(lldb) p [NSApplication sharedApplication]
(NSApplication *) $0 = 0x0000000101f0b220
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.