Skip to content

Crash when debugging with lldb on MacOS #4769

Open
@UnityAlex

Description

@UnityAlex

Description

When using a native lldb debugger attached to CoreCLR on MacOS (ARM64) breakpoints in certain locations can cause the process to crash.

Reproduction Steps

Sample code:

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("Hello, World!");
        Console.ReadKey();
        string foo = null;
        Console.WriteLine($"foo: {foo.Length}");
    }
}

The idea of the sample is to trigger the native exception handling for a null reference exception. Which is where we have our breakpoint in lldb.

  1. Run sample
  2. attach lldb debugger to process
  3. put a breakpoint on function PAL_DispatchException: breakpoint set --name PAL_DispatchException
  4. Press a key in the CoreCLR console for the running process to trigger the exception
  5. See the breakpoint hit in lldb, usually in some memmove on an access violation
  6. Attempt to continue, silent crash occurs. If you wait long enough MacOS will usually give you a dialog with a crash report. It looks like there might be a stack overflow in the exception handling.

Expected behavior

No crash

Actual behavior

Silent crash.

Regression?

No response

Known Workarounds

No response

Configuration

.net version 8.0.201
MacOS -- 14.5
M1 ARM64
Does not happen on windows. I haven't tried linux yet.

Other information

If it helps the beginning few frames of what I suspect is an overflow looks like:

0   libcoreclr.dylib                         0x3289a5d4c CorUnix::GetCurrentPalThread() + 0 (thread.hpp:684) [inlined]
1   libcoreclr.dylib                         0x3289a5d4c CorUnix::InternalGetCurrentThread() + 0 (thread.hpp:689) [inlined]
2   libcoreclr.dylib                         0x3289a5d4c PAL_DispatchException + 36 (machexception.cpp:428)
3   libcoreclr.dylib                         0x3289a5a2c PAL_DispatchExceptionWrapper + 16 (dispatchexceptionwrapper.S:39)
4   libcoreclr.dylib                         0x3289a5d4c PAL_DispatchException + 36 (machexception.cpp:422)
5   libcoreclr.dylib                         0x3289a5a2c PAL_DispatchExceptionWrapper + 16 (dispatchexceptionwrapper.S:39)
6   libcoreclr.dylib                         0x3289a5d4c PAL_DispatchException + 36 (machexception.cpp:422)
7   libcoreclr.dylib                         0x3289a5a2c PAL_DispatchExceptionWrapper + 16 (dispatchexceptionwrapper.S:39)
8   libcoreclr.dylib                         0x3289a5d4c PAL_DispatchException + 36 (machexception.cpp:422)
9   libcoreclr.dylib                         0x3289a5a2c PAL_DispatchExceptionWrapper + 16 (dispatchexceptionwrapper.S:39)
10  libcoreclr.dylib                         0x3289a5d4c PAL_DispatchException + 36 (machexception.cpp:422)
11  libcoreclr.dylib                         0x3289a5a2c PAL_DispatchExceptionWrapper + 16 (dispatchexceptionwrapper.S:39)

This is followed by 500 ish more frames of the same thing.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions