mach: Restructure exception server to separate protected exception cases [crashpad/crashpad : main]

7 views
Skip to first unread message

Justin Cohen (Gerrit)

unread,
May 29, 2026, 12:53:08 PM (8 days ago) May 29
to crashpa...@luci-project-accounts.iam.gserviceaccount.com, Mark Mentovai, David Benjamin, crashp...@chromium.org
Attention needed from Mark Mentovai

Justin Cohen added 8 comments

Patchset-level comments
File-level comment, Patchset 2:
Justin Cohen . resolved

I don't love this. Is there a better way to do this?

Mark Mentovai

I don't love this. Is there a better way to do this?

What do you think of this suggestion?

Justin Cohen

Done

Commit Message
Line 18, Patchset 2:Wrap the bodies of these cases in a compile-time if constexpr check
so they are only compiled and instantiated when Traits = MachExcTraits,
resolving compile-time type-safety issues.
Mark Mentovai . resolved

When the changes are made, adjust this accordingly.

Justin Cohen

Done

File util/mach/exc_server_variants.cc
Line 487, Patchset 2: case MachExcTraits::kMachMessageIDExceptionRaiseIdentityProtected: {
Mark Mentovai . resolved

Here’s what I suggest:

1. Remove the `default:` label from this `switch` statement. See (5) below for the new way to handle that case.
2. After this `switch` statement, introduce _a new_ `switch` statement, but put it inside a single `if constexpr` (as on your line 490, modified by my comment there).
3. Move the handling of these two message types into that new `switch` statement.
4. This `case` line, and the one for `kMachMessageIDExceptionRaiseIdentityProtected`, will now be “protected” by the `if constexpr`, so you can rewrite `MachExcTraits` to the more natural and correct `Traits`.
5. Instead of ` default:` label in either `switch` statement, this function will change to put the code formerly in the `default:` label to be beyond both `switch` statements, outside of the `if constexpr`.

It’s a small amount of additional hoisting, but I bet that the diff will remain essentially as clean as it is now, with primarily only whitespace indentation changes. The structure of the code will be cleaner and much more logical. The abuse of `MachExcTraits` values for `exc`-subsystem requests will come to an end.

The new structure may even enable further cleanups.

Justin Cohen

Done

Line 490, Patchset 2: if constexpr (!std::is_same_v<Traits, MachExcTraits>) {
Mark Mentovai . resolved

Frame this in the affirmative instead: you want to bail out here if `Traits` is `ExcTraits`.

Justin Cohen

Done

Line 495, Patchset 2: typename MachExcTraits::ExceptionRaiseIdentityProtectedRequest;
Mark Mentovai . resolved

This can go back to being `Traits` now.

Justin Cohen

Done

Line 498, Patchset 2: MachExcTraits::MIGCheckRequestExceptionRaiseIdentityProtected(
Mark Mentovai . resolved

This too.

Justin Cohen

Done

Line 557, Patchset 2: typename MachExcTraits::ExceptionRaiseIdentityProtectedReply;
Mark Mentovai . resolved

And this.

Justin Cohen

Done

Line 590, Patchset 2: if constexpr (!std::is_same_v<Traits, MachExcTraits>) {
Mark Mentovai . resolved

Same here, and also with the `MachExcTraits`/`Traits` changes that follow.

Justin Cohen

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Mark Mentovai
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: I1d4ae2d46d91d87aa67d5a5a5e445d1f9e2dc067
Gerrit-Change-Number: 7880932
Gerrit-PatchSet: 4
Gerrit-Owner: Justin Cohen <justi...@google.com>
Gerrit-Reviewer: David Benjamin <davi...@chromium.org>
Gerrit-Reviewer: Justin Cohen <justi...@google.com>
Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
Gerrit-Comment-Date: Fri, 29 May 2026 16:53:06 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Mark Mentovai <ma...@chromium.org>
Comment-In-Reply-To: Justin Cohen <justi...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Mark Mentovai (Gerrit)

unread,
May 29, 2026, 1:05:14 PM (8 days ago) May 29
to Justin Cohen, crashpa...@luci-project-accounts.iam.gserviceaccount.com, David Benjamin, crashp...@chromium.org
Attention needed from Justin Cohen

Mark Mentovai added 3 comments

Commit Message
Line 9, Patchset 4 (Latest):Standard 32-bit `exc` does not support identity-protected exceptions
Mark Mentovai . unresolved

It’s no longer the standard. How about:

“In contrast to to the modern `mach_exc`, the original 32-bit `exc` does not…”

?

Line 25, Patchset 4 (Latest):This elegant restructuring ensures protected exception cases are only
Mark Mentovai . resolved

yes. elegant.

File util/mach/exc_server_variants.cc
Line 487, Patchset 4 (Latest): if constexpr (std::is_same_v<Traits, MachExcTraits>) {
Mark Mentovai . unresolved

You still need `<type_traits>` for this. (You added it before, but now it got lost!)

Open in Gerrit

Related details

Attention is currently required from:
  • Justin Cohen
Submit Requirements:
    • requirement 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: I1d4ae2d46d91d87aa67d5a5a5e445d1f9e2dc067
    Gerrit-Change-Number: 7880932
    Gerrit-PatchSet: 4
    Gerrit-Owner: Justin Cohen <justi...@google.com>
    Gerrit-Reviewer: David Benjamin <davi...@chromium.org>
    Gerrit-Reviewer: Justin Cohen <justi...@google.com>
    Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
    Gerrit-Attention: Justin Cohen <justi...@google.com>
    Gerrit-Comment-Date: Fri, 29 May 2026 17:05:10 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Justin Cohen (Gerrit)

    unread,
    May 29, 2026, 1:07:00 PM (8 days ago) May 29
    to crashpa...@luci-project-accounts.iam.gserviceaccount.com, Mark Mentovai, David Benjamin, crashp...@chromium.org
    Attention needed from Mark Mentovai

    Justin Cohen added 1 comment

    Commit Message
    Line 25, Patchset 4 (Latest):This elegant restructuring ensures protected exception cases are only
    Mark Mentovai . resolved

    yes. elegant.

    Justin Cohen

    arg, I snipped that out and it snuck back in. patchset 3 was the correct one. This is what I get for letting an LLM write english.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Mark Mentovai
    Submit Requirements:
    • requirement 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: I1d4ae2d46d91d87aa67d5a5a5e445d1f9e2dc067
    Gerrit-Change-Number: 7880932
    Gerrit-PatchSet: 4
    Gerrit-Owner: Justin Cohen <justi...@google.com>
    Gerrit-Reviewer: David Benjamin <davi...@chromium.org>
    Gerrit-Reviewer: Justin Cohen <justi...@google.com>
    Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
    Gerrit-Attention: Mark Mentovai <ma...@chromium.org>
    Gerrit-Comment-Date: Fri, 29 May 2026 17:06:58 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Mark Mentovai <ma...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Mark Mentovai (Gerrit)

    unread,
    May 29, 2026, 1:12:54 PM (8 days ago) May 29
    to Justin Cohen, crashpa...@luci-project-accounts.iam.gserviceaccount.com, David Benjamin, crashp...@chromium.org
    Attention needed from Justin Cohen

    Mark Mentovai added 2 comments

    Commit Message
    Line 20, Patchset 6:into two distinct switch statements: 1. A switch statement for standard
    exceptions compiled for all Traits. 2. A switch statement for
    identity-protected exceptions nested inside
    a single `if constexpr (std::is_same_v<Traits, MachExcTraits>)`
    block.
    Mark Mentovai . unresolved

    You undid the line-per-list-item organization for 1. and 2. (by accident?), but these two indented lines were left as though it’s still organized with a separate line per list item.

    Line 25, Patchset 4:This elegant restructuring ensures protected exception cases are only
    Mark Mentovai . resolved

    yes. elegant.

    Justin Cohen

    arg, I snipped that out and it snuck back in. patchset 3 was the correct one. This is what I get for letting an LLM write english.

    Mark Mentovai

    arg, I snipped that out and it snuck back in. patchset 3 was the correct one. This is what I get for letting an LLM write english.

    I recommend against that. Seeing what you think a change should do in English lets me review it to make sure that it actually does that.

    If you (or a tool) write a change in code, then the LLM-generated commit message can only, at best, describe what your code actually does, which might not be what you intend for it to do. If you had a tool write your code for you, this is especially important.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Justin Cohen
    Submit Requirements:
    • requirement 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: I1d4ae2d46d91d87aa67d5a5a5e445d1f9e2dc067
    Gerrit-Change-Number: 7880932
    Gerrit-PatchSet: 6
    Gerrit-Owner: Justin Cohen <justi...@google.com>
    Gerrit-Reviewer: David Benjamin <davi...@chromium.org>
    Gerrit-Reviewer: Justin Cohen <justi...@google.com>
    Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
    Gerrit-Attention: Justin Cohen <justi...@google.com>
    Gerrit-Comment-Date: Fri, 29 May 2026 17:12:51 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Mark Mentovai <ma...@chromium.org>
    Comment-In-Reply-To: Justin Cohen <justi...@google.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Mark Mentovai (Gerrit)

    unread,
    May 29, 2026, 1:14:53 PM (8 days ago) May 29
    to Justin Cohen, crashpa...@luci-project-accounts.iam.gserviceaccount.com, David Benjamin, crashp...@chromium.org
    Attention needed from Justin Cohen

    Mark Mentovai voted and added 1 comment

    Votes added by Mark Mentovai

    Code-Review+1

    1 comment

    Commit Message
    Line 20, Patchset 6:into two distinct switch statements: 1. A switch statement for standard
    exceptions compiled for all Traits. 2. A switch statement for
    identity-protected exceptions nested inside
    a single `if constexpr (std::is_same_v<Traits, MachExcTraits>)`
    block.
    Mark Mentovai . resolved

    You undid the line-per-list-item organization for 1. and 2. (by accident?), but these two indented lines were left as though it’s still organized with a separate line per list item.

    Mark Mentovai

    You undid the line-per-list-item organization for 1. and 2. (by accident?), but these two indented lines were left as though it’s still organized with a separate line per list item.

    (if it helps: sometimes having a leading space on the 1. or - helps your reformatter understand that it’s a list. Like:

    ```
    - A switch statement for identity-protected exceptions nested inside

    a single `if constexpr (std::is_same_v<Traits, MachExcTraits>)`
    block.
    ```

    instead of:

    ```
    - A switch statement for identity-protected exceptions nested inside

    a single `if constexpr (std::is_same_v<Traits, MachExcTraits>)` block.

    Related details

    Attention is currently required from:
    • Justin Cohen
    Submit Requirements:
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • 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: I1d4ae2d46d91d87aa67d5a5a5e445d1f9e2dc067
    Gerrit-Change-Number: 7880932
    Gerrit-PatchSet: 8
    Gerrit-Owner: Justin Cohen <justi...@google.com>
    Gerrit-Reviewer: David Benjamin <davi...@chromium.org>
    Gerrit-Reviewer: Justin Cohen <justi...@google.com>
    Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
    Gerrit-Attention: Justin Cohen <justi...@google.com>
    Gerrit-Comment-Date: Fri, 29 May 2026 17:14:51 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Mark Mentovai <ma...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Justin Cohen (Gerrit)

    unread,
    May 29, 2026, 1:26:26 PM (8 days ago) May 29
    to Mark Mentovai, crashpa...@luci-project-accounts.iam.gserviceaccount.com, David Benjamin, crashp...@chromium.org

    Justin Cohen added 2 comments

    Commit Message
    Line 9, Patchset 4:Standard 32-bit `exc` does not support identity-protected exceptions
    Mark Mentovai . resolved

    It’s no longer the standard. How about:

    “In contrast to to the modern `mach_exc`, the original 32-bit `exc` does not…”

    ?

    Justin Cohen

    Done

    File util/mach/exc_server_variants.cc
    Line 487, Patchset 4: if constexpr (std::is_same_v<Traits, MachExcTraits>) {
    Mark Mentovai . resolved

    You still need `<type_traits>` for this. (You added it before, but now it got lost!)

    Justin Cohen

    Done

    Open in Gerrit

    Related details

    Attention set is empty
    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: I1d4ae2d46d91d87aa67d5a5a5e445d1f9e2dc067
      Gerrit-Change-Number: 7880932
      Gerrit-PatchSet: 8
      Gerrit-Owner: Justin Cohen <justi...@google.com>
      Gerrit-Reviewer: David Benjamin <davi...@chromium.org>
      Gerrit-Reviewer: Justin Cohen <justi...@google.com>
      Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
      Gerrit-Comment-Date: Fri, 29 May 2026 17:26:23 +0000
      satisfied_requirement
      open
      diffy

      Justin Cohen (Gerrit)

      unread,
      Jun 2, 2026, 8:10:30 AM (4 days ago) Jun 2
      to Mark Mentovai, crashpa...@luci-project-accounts.iam.gserviceaccount.com, David Benjamin, crashp...@chromium.org

      Justin Cohen voted Commit-Queue+2

      Commit-Queue+2
      Open in Gerrit

      Related details

      Attention set is empty
      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: I1d4ae2d46d91d87aa67d5a5a5e445d1f9e2dc067
      Gerrit-Change-Number: 7880932
      Gerrit-PatchSet: 9
      Gerrit-Owner: Justin Cohen <justi...@google.com>
      Gerrit-Reviewer: David Benjamin <davi...@chromium.org>
      Gerrit-Reviewer: Justin Cohen <justi...@google.com>
      Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
      Gerrit-Comment-Date: Tue, 02 Jun 2026 12:10:28 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy

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

      unread,
      Jun 2, 2026, 8:23:53 AM (4 days ago) Jun 2
      to Justin Cohen, Mark Mentovai, David Benjamin, crashp...@chromium.org

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

      Unreviewed changes

      8 is the latest approved patch-set.
      No files were changed between the latest approved patch-set and the submitted one.

      Change information

      Commit message:
      mach: Restructure exception server to separate protected exception cases

      In contrast to to the modern mach_exc, the original 32-bit exc does not
      support identity-protected exceptions (e.g.,
      EXCEPTION_IDENTITY_PROTECTED). Under the previous unified switch
      statement design, the protected cases in ExcServer<Traits>::
      MachMessageServerFunction were compiled (but dead) when Traits =
      ExcTraits. This forced the use of raw pointer type casts to compile
      mismatched exception code arrays (casting 64-bit exception codes to
      32-bit exception codes), which was flagged during spanification and by
      UBSan.

      This change restructures the MachMessageServerFunction by splitting it

      into two distinct switch statements:
      - A switch statement for standard exceptions compiled for all Traits.

      - A switch statement for identity-protected exceptions nested inside
        a single `if constexpr (std::is_same_v<Traits, MachExcTraits>)` block.

      This ensures protected exception cases are only compiled and
      instantiated when Traits = MachExcTraits.
      Bug: 401232341
      Change-Id: I1d4ae2d46d91d87aa67d5a5a5e445d1f9e2dc067
      Commit-Queue: Justin Cohen <justi...@google.com>
      Reviewed-by: Mark Mentovai <ma...@chromium.org>
      Files:
      • M util/mach/exc_server_variants.cc
      Change size: L
      Delta: 1 file changed, 182 insertions(+), 177 deletions(-)
      Branch: refs/heads/main
      Submit Requirements:
      • requirement satisfiedCode-Review: +1 by Mark Mentovai
      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: I1d4ae2d46d91d87aa67d5a5a5e445d1f9e2dc067
      Gerrit-Change-Number: 7880932
      Gerrit-PatchSet: 10
      Gerrit-Owner: Justin Cohen <justi...@google.com>
      Gerrit-Reviewer: David Benjamin <davi...@chromium.org>
      Gerrit-Reviewer: Justin Cohen <justi...@google.com>
      Gerrit-Reviewer: Mark Mentovai <ma...@chromium.org>
      open
      diffy
      satisfied_requirement
      Reply all
      Reply to author
      Forward
      0 new messages