[all-commits] [llvm/llvm-project] 52de49: [lldb][debugserver][MacOSX] Work around sanitizer ...

Michael Buch via All-commits all-commits at lists.llvm.org
Fri Mar 21 04:21:52 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 52de49e4b9cd69957b7dc50a5fed061ecd0b0d77
      https://github.com/llvm/llvm-project/commit/52de49e4b9cd69957b7dc50a5fed061ecd0b0d77
  Author: Michael Buch <michaelbuch12 at gmail.com>
  Date:   2025-03-21 (Fri, 21 Mar 2025)

  Changed paths:
    M lldb/tools/debugserver/source/MacOSX/MachException.cpp
    M lldb/tools/debugserver/source/MacOSX/MachException.h

  Log Message:
  -----------
  [lldb][debugserver][MacOSX] Work around sanitizer misaligned address errors when reading exception data (#132193)

We've been dealing with UBSAN issues around this code for some time now
(see `9c36859b33b386fbfa9599646de1e2ae01158180` and
`1a2122e9e9d1d495fdf337a4a9445b61ca56df6f`). On recent macOS versions, a
UBSAN-enabled debugserver will crash when performing a `memcpy` of the
input `mach_exception_data_t`. The pointer to the beginning of the
exception data may not be aligned on a doubleword boundary, leading to
UBSAN failures such as:
```
$ ./bin/debugserver 0.0.0.0:5555 /Volumes/SSD/llvm-builds/llvm-worktrees/clang-work/build-sanitized-release/tools/lldb/test/Shell/Recognizer/Output/verbose_trap.test.tmp.out
/Volumes/SSD/llvm-builds/llvm-worktrees/clang-work/lldb/tools/debugserver/source/MacOSX/MachException.cpp:35:12: runtime error: store to misaligned address 0x00016ddfa634 for type 'mach_exception_data_type_t *' (aka 'long long *'), which requires 8 byte alignment
0x00016ddfa634: note: pointer points here
  02 00 00 00 03 00 01 00  00 00 00 00 11 00 00 00  00 00 00 00 00 00 00 00  08 00 00 00 00 00 00 00
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Volumes/SSD/llvm-builds/llvm-worktrees/clang-work/lldb/tools/debugserver/source/MacOSX/MachException.cpp:35:12
```

Work around these failures by pretending the input data is a `char*`
buffer.

Drive-by changes:
* I factored out some duplicated code into a static
`AppendExceptionData` and made the types consistent

---------

Co-authored-by: Jonas Devlieghere <jonas at devlieghere.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list