Repository navigation
Add opt-in hardware breakpoints for SOS JIT breakpoints - #6081
Merged
max-charlamb merged 1 commit intoOct 2, 2026
Merged
max-charlamb merged 1 commit into
max-charlamb merged 1 commit into
Conversation
Setting SOS_LLDB_HARDWARE_JIT_BREAKPOINTS=1 makes SOS append --hardware to the LLDB breakpoints it plants in JIT code (bpmd and exception catchers). On macOS arm64, debugserver writes a software breakpoint by copy-on-writing the MAP_JIT page (mach_vm_protect with VM_PROT_COPY) and patching in a BRK. Threads that then run code on the new page can intermittently take a spurious EXC_BAD_ACCESS/KERN_PROTECTION_FAILURE instruction abort. Hardware breakpoints use debug registers and never modify the page. The SOS test harness opts in for live LLDB hosts on macOS arm64. Only a few hardware breakpoint slots exist (6 on Apple M-series), and setting more fails rather than falling back to software breakpoints. Co-authored-by: Copilot <[email protected]>
hoyosjs
approved these changes
Oct 2, 2026
Member
Author
|
/ba-g unrelated test failure (legacy SOS tests) |
max-charlamb
deleted the
dev/max-charlamb/lldb-hardware-jit-breakpoints
branch
October 2, 2026 20:06
This was referenced Oct 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in environment variable,
SOS_LLDB_HARDWARE_JIT_BREAKPOINTS=1. When set, SOS appends--hardwareto the LLDB breakpoints it plants in JIT code:bpmd(IssueDebuggerBPCommand) and the one-shot exception-catcher breakpoint. The SOS test harness sets it for live LLDB hosts on macOS arm64.Why
On macOS arm64, a live LLDB
bpmdtest intermittently crashes the debuggee withEXC_BAD_ACCESS/KERN_PROTECTION_FAILURE. The ESR is0x8200000f, an instruction-abort permission fault with FAR == PC in JIT code, and the fault clears on retry.Debugserver writes a software breakpoint like this:
mach_vm_protect(RW | VM_PROT_COPY), which copy-on-writes theMAP_JITpage.mach_vm_writeof theBRKinstruction.MATTR_CACHEflush.RX.Other threads that execute from the freshly copied page can briefly take a spurious permission fault. A standalone C repro that performs the same sequence, with no debugger involved, reproduces it on macOS 27 / M3 Pro. It does not reproduce when the page is patched in-process with
pthread_jit_write_protect_np, or in a macOS VM. This is being reported to Apple.Hardware breakpoints are programmed through the ARM debug registers and never modify the page, so they avoid the problem.
Local GcWhere replay on stock CLT LLDB (lldb-2103), with SOS hosted on .NET 11:
Earlier runs with the
sos-lldbdriver:Limitations
Testing
GcWhereTestsandLiveBpmdTests(live LLDB, Core net8/net10/net11, legacy DAC and cDAC) pass locally on osx-arm64.--hardware(16/16).