Fix ExceptionInfo() for an EXC_RESOURCE recovered from EXC_CRASH [crashpad/crashpad : main]

23 views
Skip to first unread message

ZhengHao (Gerrit)

unread,
Sep 23, 2026, 7:42:23 AMSep 23
to Mark Mentovai, crashp...@chromium.org
Attention needed from Mark Mentovai

ZhengHao added 1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
ZhengHao . resolved

Hi, this fixes ExceptionSnapshotMac::Initialize() applying the EXC_RESOURCE/EXC_GUARD high-bit extraction to a code[0] recovered from an EXC_CRASH wrapper. That value retains only its low 20 bits, so the shift always yields 0 and ExceptionInfo() reports no payload.

Observed on macOS 26.2 where the kernel wrapped an EXC_RESOURCE in EXC_CRASH after a resource-limit SIGKILL. ExcCrashCouldContainException() already rejects the pairing but Initialize() only logs and continues. Added the observed code[0] to the existing test.

Details: https://issues.chromium.org/issues/563877890

Open in Gerrit

Related details

Attention is currently required from:
  • Mark Mentovai
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: crashpad/crashpad
Gerrit-Branch: main
Gerrit-Change-Id: Id70c3f9dbafc71fb5309167a9758d4e7e2ad42c2
Gerrit-Change-Number: 8450410
Gerrit-PatchSet: 1
Gerrit-Owner: ZhengHao <zheng...@bytedance.com>
Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
Gerrit-Comment-Date: Wed, 23 Sep 2026 08:21:18 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy

Mark Mentovai (Gerrit)

unread,
Sep 23, 2026, 3:30:57 PMSep 23
to ZhengHao, crashp...@chromium.org
Attention needed from ZhengHao

Mark Mentovai added 4 comments

Patchset-level comments
Mark Mentovai . resolved

I think when I

Commit Message
Line 28, Patchset 1 (Latest):Bug: 563877890
Mark Mentovai . unresolved

You don’t need Bug: if you’re putting the same bug in Fixed:.

File snapshot/mac/exception_snapshot_mac.cc
Line 91, Patchset 1 (Latest): if (!recovered_from_exc_crash &&
(exception_ == EXC_RESOURCE || exception_ == EXC_GUARD)) {
Mark Mentovai . unresolved

When I wrote this, `EXC_RESOURCE` and `EXC_GUARD` wouldn’t be wrapped in `EXC_CRASH`, so we had to handle them distinctly.

If that’s changed, it might be possible to simplify things considerably. For example, we can avoid registering as an `EXC_RESOURCE` handler, get rid of things like `crashpad::IsExceptionNonfatalResource`, and just take fatal resource exceptions wrapped in `EXC_CRASH`. We may need to suppress ReportCrash from claiming `EXC_RESOURCE` at the task level, such as by clearing it, as ReportCrash is a task-default `EXC_RESOURCE` handler.

Of course, doing so, you’d be limiting code[0] to the lower 20 bits, which is what your new comment states. And maybe that’s not enough for these exceptions.

Do you have thoughts?

File util/mach/exception_types_test.cc
Line 59, Patchset 1 (Latest): // EXC_CRASH when a process is SIGKILLed for a resource limit, even though
// ExcCrashCouldContainException() rejects that pairing. Only the low 20
Mark Mentovai . unresolved

`crashpad::ExcCrashCouldContainException` should be fixed.

In order to do so, you’ll find out where this changed by examining xnu’s change history, because the fix may wind up being OS version-specific.

Open in Gerrit

Related details

Attention is currently required from:
  • ZhengHao
Submit Requirements:
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: crashpad/crashpad
    Gerrit-Branch: main
    Gerrit-Change-Id: Id70c3f9dbafc71fb5309167a9758d4e7e2ad42c2
    Gerrit-Change-Number: 8450410
    Gerrit-PatchSet: 1
    Gerrit-Owner: ZhengHao <zheng...@bytedance.com>
    Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
    Gerrit-Attention: ZhengHao <zheng...@bytedance.com>
    Gerrit-Comment-Date: Wed, 23 Sep 2026 19:30:53 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    ZhengHao (Gerrit)

    unread,
    Sep 24, 2026, 2:42:49 AMSep 24
    to Mark Mentovai, crashp...@chromium.org
    Attention needed from Mark Mentovai

    ZhengHao added 4 comments

    Commit Message
    Line 28, Patchset 1:Bug: 563877890
    Mark Mentovai . resolved

    You don’t need Bug: if you’re putting the same bug in Fixed:.

    ZhengHao

    Done

    Line 28, Patchset 1:Bug: 563877890
    Mark Mentovai . resolved

    You don’t need Bug: if you’re putting the same bug in Fixed:.

    ZhengHao

    Done

    File snapshot/mac/exception_snapshot_mac.cc
    Line 91, Patchset 1: if (!recovered_from_exc_crash &&

    (exception_ == EXC_RESOURCE || exception_ == EXC_GUARD)) {
    Mark Mentovai . resolved

    When I wrote this, `EXC_RESOURCE` and `EXC_GUARD` wouldn’t be wrapped in `EXC_CRASH`, so we had to handle them distinctly.

    If that’s changed, it might be possible to simplify things considerably. For example, we can avoid registering as an `EXC_RESOURCE` handler, get rid of things like `crashpad::IsExceptionNonfatalResource`, and just take fatal resource exceptions wrapped in `EXC_CRASH`. We may need to suppress ReportCrash from claiming `EXC_RESOURCE` at the task level, such as by clearing it, as ReportCrash is a task-default `EXC_RESOURCE` handler.

    Of course, doing so, you’d be limiting code[0] to the lower 20 bits, which is what your new comment states. And maybe that’s not enough for these exceptions.

    Do you have thoughts?

    ZhengHao

    I'd lean against dropping it. Removing the handler doesn't recover the lost bits — a recovered code[0] only carries 20 bits — and it would lose the native 64-bit decoding path for direct non-fatal EXC_RESOURCE deliveries. Reading the real type from the corpse's crashinfo is a separate change.

    File util/mach/exception_types_test.cc
    Line 59, Patchset 1: // EXC_CRASH when a process is SIGKILLed for a resource limit, even though

    // ExcCrashCouldContainException() rejects that pairing. Only the low 20
    Mark Mentovai . resolved

    `crashpad::ExcCrashCouldContainException` should be fixed.

    In order to do so, you’ll find out where this changed by examining xnu’s change history, because the fix may wind up being OS version-specific.

    ZhengHao

    Done. I checked proc_prepareexit() from xnu-1504 (macOS 10.7) through xnu-12377 (macOS 26.2): the packing and EXC_CRASH delivery are unchanged, and the kernel has always delivered a resource-limit SIGKILL this way. No version gate is needed. The EXC_GUARD < 13 gate stays.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Mark Mentovai
    Submit Requirements:
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: crashpad/crashpad
      Gerrit-Branch: main
      Gerrit-Change-Id: Id70c3f9dbafc71fb5309167a9758d4e7e2ad42c2
      Gerrit-Change-Number: 8450410
      Gerrit-PatchSet: 3
      Gerrit-Owner: ZhengHao <zheng...@bytedance.com>
      Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
      Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
      Gerrit-Comment-Date: Thu, 24 Sep 2026 06:42:43 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Mark Mentovai <ma...@chromium.org>
      unsatisfied_requirement
      open
      diffy

      Mark Mentovai (Gerrit)

      unread,
      Sep 24, 2026, 9:53:46 AMSep 24
      to ZhengHao, crashp...@chromium.org
      Attention needed from ZhengHao

      Mark Mentovai added 1 comment

      File snapshot/mac/exception_snapshot_mac.cc
      Line 91, Patchset 1: if (!recovered_from_exc_crash &&
      (exception_ == EXC_RESOURCE || exception_ == EXC_GUARD)) {
      Mark Mentovai . resolved

      When I wrote this, `EXC_RESOURCE` and `EXC_GUARD` wouldn’t be wrapped in `EXC_CRASH`, so we had to handle them distinctly.

      If that’s changed, it might be possible to simplify things considerably. For example, we can avoid registering as an `EXC_RESOURCE` handler, get rid of things like `crashpad::IsExceptionNonfatalResource`, and just take fatal resource exceptions wrapped in `EXC_CRASH`. We may need to suppress ReportCrash from claiming `EXC_RESOURCE` at the task level, such as by clearing it, as ReportCrash is a task-default `EXC_RESOURCE` handler.

      Of course, doing so, you’d be limiting code[0] to the lower 20 bits, which is what your new comment states. And maybe that’s not enough for these exceptions.

      Do you have thoughts?

      ZhengHao

      I'd lean against dropping it. Removing the handler doesn't recover the lost bits — a recovered code[0] only carries 20 bits — and it would lose the native 64-bit decoding path for direct non-fatal EXC_RESOURCE deliveries. Reading the real type from the corpse's crashinfo is a separate change.

      Mark Mentovai

      If we’re leaving it, I’ve got to ask:

      Since the kernel can wrap `EXC_RESOURCE` and `EXC_GUARD` in `EXC_CRASH`, and since we’re registering as the handler for all three, is it possible that we’ll receive the same exception _twice_, once unwrapped and then again wrapped?

      Open in Gerrit

      Related details

      Attention is currently required from:
      • ZhengHao
      Submit Requirements:
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: crashpad/crashpad
      Gerrit-Branch: main
      Gerrit-Change-Id: Id70c3f9dbafc71fb5309167a9758d4e7e2ad42c2
      Gerrit-Change-Number: 8450410
      Gerrit-PatchSet: 4
      Gerrit-Owner: ZhengHao <zheng...@bytedance.com>
      Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
      Gerrit-Attention: ZhengHao <zheng...@bytedance.com>
      Gerrit-Comment-Date: Thu, 24 Sep 2026 13:53:43 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: ZhengHao <zheng...@bytedance.com>
      Comment-In-Reply-To: Mark Mentovai <ma...@chromium.org>
      unsatisfied_requirement
      open
      diffy

      ZhengHao (Gerrit)

      unread,
      Oct 7, 2026, 11:23:07 PM (14 days ago) Oct 7
      to Mark Mentovai, crashp...@chromium.org
      Attention needed from Mark Mentovai

      ZhengHao added 1 comment

      File snapshot/mac/exception_snapshot_mac.cc
      Line 91, Patchset 1: if (!recovered_from_exc_crash &&
      (exception_ == EXC_RESOURCE || exception_ == EXC_GUARD)) {
      Mark Mentovai . resolved

      When I wrote this, `EXC_RESOURCE` and `EXC_GUARD` wouldn’t be wrapped in `EXC_CRASH`, so we had to handle them distinctly.

      If that’s changed, it might be possible to simplify things considerably. For example, we can avoid registering as an `EXC_RESOURCE` handler, get rid of things like `crashpad::IsExceptionNonfatalResource`, and just take fatal resource exceptions wrapped in `EXC_CRASH`. We may need to suppress ReportCrash from claiming `EXC_RESOURCE` at the task level, such as by clearing it, as ReportCrash is a task-default `EXC_RESOURCE` handler.

      Of course, doing so, you’d be limiting code[0] to the lower 20 bits, which is what your new comment states. And maybe that’s not enough for these exceptions.

      Do you have thoughts?

      ZhengHao

      I'd lean against dropping it. Removing the handler doesn't recover the lost bits — a recovered code[0] only carries 20 bits — and it would lose the native 64-bit decoding path for direct non-fatal EXC_RESOURCE deliveries. Reading the real type from the corpse's crashinfo is a separate change.

      Mark Mentovai

      If we’re leaving it, I’ve got to ask:

      Since the kernel can wrap `EXC_RESOURCE` and `EXC_GUARD` in `EXC_CRASH`, and since we’re registering as the handler for all three, is it possible that we’ll receive the same exception _twice_, once unwrapped and then again wrapped?

      ZhengHao

      No. The direct EXC_RESOURCE deliveries are non-fatal warnings that IsExceptionNonfatalResource() swallows without generating a report. The fatal kill goes through SIGKILL → proc_prepareexit() → EXC_CRASH, which is a separate delivery path.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Mark Mentovai
      Submit Requirements:
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: crashpad/crashpad
      Gerrit-Branch: main
      Gerrit-Change-Id: Id70c3f9dbafc71fb5309167a9758d4e7e2ad42c2
      Gerrit-Change-Number: 8450410
      Gerrit-PatchSet: 4
      Gerrit-Owner: ZhengHao <zheng...@bytedance.com>
      Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
      Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
      Gerrit-Comment-Date: Thu, 08 Oct 2026 03:22:52 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Mark Mentovai <ma...@chromium.org>
      Comment-In-Reply-To: ZhengHao <zheng...@bytedance.com>
      unsatisfied_requirement
      open
      diffy

      Mark Mentovai (Gerrit)

      unread,
      Oct 8, 2026, 9:19:01 AM (13 days ago) Oct 8
      to ZhengHao, crashp...@chromium.org
      Attention needed from ZhengHao

      Mark Mentovai voted Code-Review+1

      Code-Review+1
      Open in Gerrit

      Related details

      Attention is currently required from:
      • ZhengHao
      Submit Requirements:
      • requirement satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: crashpad/crashpad
      Gerrit-Branch: main
      Gerrit-Change-Id: Id70c3f9dbafc71fb5309167a9758d4e7e2ad42c2
      Gerrit-Change-Number: 8450410
      Gerrit-PatchSet: 4
      Gerrit-Owner: ZhengHao <zheng...@bytedance.com>
      Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
      Gerrit-Attention: ZhengHao <zheng...@bytedance.com>
      Gerrit-Comment-Date: Thu, 08 Oct 2026 13:18:58 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Hewro Hewei (Gerrit)

      unread,
      Oct 8, 2026, 11:39:55 PM (13 days ago) Oct 8
      to ZhengHao, crashpa...@luci-project-accounts.iam.gserviceaccount.com, Mark Mentovai, crashp...@chromium.org
      Attention needed from ZhengHao

      Hewro Hewei voted Code-Review+1

      Code-Review+1
      Open in Gerrit

      Related details

      Attention is currently required from:
      • ZhengHao
      Submit Requirements:
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: crashpad/crashpad
      Gerrit-Branch: main
      Gerrit-Change-Id: Id70c3f9dbafc71fb5309167a9758d4e7e2ad42c2
      Gerrit-Change-Number: 8450410
      Gerrit-PatchSet: 4
      Gerrit-Owner: ZhengHao <zheng...@bytedance.com>
      Gerrit-Reviewer: Hewro Hewei <ihe...@chromium.org>
      Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
      Gerrit-Attention: ZhengHao <zheng...@bytedance.com>
      Gerrit-Comment-Date: Fri, 09 Oct 2026 03:39:48 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy

      Hewro Hewei (Gerrit)

      unread,
      Oct 8, 2026, 11:40:03 PM (13 days ago) Oct 8
      to ZhengHao, crashpa...@luci-project-accounts.iam.gserviceaccount.com, Mark Mentovai, crashp...@chromium.org
      Attention needed from ZhengHao

      Hewro Hewei voted Commit-Queue+2

      Commit-Queue+2
      Open in Gerrit

      Related details

      Attention is currently required from:
      • ZhengHao
      Submit Requirements:
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: crashpad/crashpad
      Gerrit-Branch: main
      Gerrit-Change-Id: Id70c3f9dbafc71fb5309167a9758d4e7e2ad42c2
      Gerrit-Change-Number: 8450410
      Gerrit-PatchSet: 4
      Gerrit-Owner: ZhengHao <zheng...@bytedance.com>
      Gerrit-Reviewer: Hewro Hewei <ihe...@chromium.org>
      Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
      Gerrit-Attention: ZhengHao <zheng...@bytedance.com>
      Gerrit-Comment-Date: Fri, 09 Oct 2026 03:39:55 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy

      crashpad-scoped@luci-project-accounts.iam.gserviceaccount.com (Gerrit)

      unread,
      Oct 8, 2026, 11:51:44 PM (13 days ago) Oct 8
      to ZhengHao, Hewro Hewei, Mark Mentovai, crashp...@chromium.org

      crashpa...@luci-project-accounts.iam.gserviceaccount.com submitted the change

      Change information

      Commit message:
      Fix ExceptionInfo() for an EXC_RESOURCE recovered from EXC_CRASH

      When Initialize() recovers the original exception from an EXC_CRASH
      wrapper, it still applies the EXC_RESOURCE/EXC_GUARD high-bit extraction
      to code[0]. proc_prepareexit() packs only the low 20 bits of the
      original code[0] into the wrapper, so the shift always yields 0 and
      ExceptionInfo() reports nothing.

      Skip the extraction for a recovered code[0], stop excluding EXC_RESOURCE
      in ExcCrashCouldContainException(), and add the observed code[0]
      0x9b4aaaa to the test data.
      Fixed: 563877890
      Change-Id: Id70c3f9dbafc71fb5309167a9758d4e7e2ad42c2
      Reviewed-by: Hewro Hewei <ihe...@chromium.org>
      Commit-Queue: Hewro Hewei <ihe...@chromium.org>
      Reviewed-by: Mark Mentovai <ma...@chromium.org>
      Files:
      • M snapshot/mac/exception_snapshot_mac.cc
      • M util/mach/exception_types.cc
      • M util/mach/exception_types_test.cc
      Change size: S
      Delta: 3 files changed, 18 insertions(+), 13 deletions(-)
      Branch: refs/heads/main
      Submit Requirements:
      • requirement satisfiedCode-Review: +1 by Mark Mentovai, +1 by Hewro Hewei
      • requirement satisfiedReview-Enforcement: Code-Review+1 by Mark Mentovai, Code-Review+1 by Hewro Hewei
      Open in Gerrit
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: merged
      Gerrit-Project: crashpad/crashpad
      Gerrit-Branch: main
      Gerrit-Change-Id: Id70c3f9dbafc71fb5309167a9758d4e7e2ad42c2
      Gerrit-Change-Number: 8450410
      Gerrit-PatchSet: 5
      Gerrit-Owner: ZhengHao <zheng...@bytedance.com>
      Gerrit-Reviewer: Hewro Hewei <ihe...@chromium.org>
      Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
      open
      diffy
      satisfied_requirement
      Reply all
      Reply to author
      Forward
      0 new messages