This is an archive of the discontinued LLVM Phabricator instance.

[debugserver] align received mach exception data before accessing it as array of uint64_t's, fix UB sanitizer failure

Authored by jasonmolenda on Aug 18 2023, 2:21 PM.



The mach exception data received in debugserver is not aligned to a doubleword boundary. Most of these were fixed in 2017 by Vedant ([MachException] Avoid alignment UB, NFC) but there was a codepath when debugserver logging is enabled where we would still access the mach exception data without aligning it first. This has been causing failures on the sanitizer greendragon bot for the last few days from Jim's change in where he is enabling LOG_EXCEPTIONS debugserver logging unconditionally (this should prob be in a self.TraceOn() conditional, or maybe not even be in the test - it looks like a debug print he forgot to remove) in the new test_shadow_listener test.

Simplest fix, and it's only done when LOG_EXCEPTIONS is enabled, is to align the data one-off for the logging.

I would have handed this to Jim to fix, but by the time I understood what the actual failure was, it was nothing to fix it.

Diff Detail

Event Timeline

jasonmolenda created this revision.Aug 18 2023, 2:21 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 18 2023, 2:21 PM
jasonmolenda requested review of this revision.Aug 18 2023, 2:21 PM

I'm going to land this one sans-approval to fix the CI bot. but I still think

self.runCmd("settings set target.process.extra-startup-command QSetLogging:bitmask=LOG_PROCESS|LOG_EXCEPTIONS|LOG_RNB_PACKETS|LOG_STEP;")

shouldn't be in a test case, even though it helpfully found this ubsan issue.

This revision was not accepted when it landed; it landed in state Needs Review.Aug 18 2023, 3:34 PM
This revision was automatically updated to reflect the committed changes.