Closed Bug 1724368 Opened 2 years ago Closed 2 years ago

Catch `EXC_RESOURCE` exceptions on macOS


(Toolkit :: Crash Reporting, enhancement)




93 Branch
Tracking Status
firefox93 --- fixed


(Reporter: gsvelto, Assigned: gsvelto)


(Blocks 2 open bugs, )



(1 file, 1 obsolete file)

We need to catch EXC_RESOURCE exceptions on macOS as they cover a variety of crashes that can happen when exceeding certain resource thresholds.

The various types of resources and how their data is in the exception code field are documented here.

To implement this we need to do the following:

  • Add the EXC_RESOURCE exception to the list of exceptions we request to be notified of in the mac exception handler
  • Modify the mac minidump writer to account for these exception and store the code field correctly in the minidump
  • Adjust the minidump processor to properly decode the exception code field and print out its contents

Once we'll have applied these changes to mozilla-central I'll need to file another bug to import them in Socorro's stack-walker.

Blocks: 1724215

Corresponding issue in rust-minidump

Summary: Catch `EXC_RESOURCE` on macOS → Catch `EXC_RESOURCE` exceptions on macOS

This introduces a few changes to the crash reporting machinery:

  • The macOS exception handler now registers itself for catching EXC_RESOURCE
    exceptions, those are thrown when the process exceeds a pre-set resource
    limit (memory, CPU usage, I/O, etc...)
  • The minidump writer has been updated to correctly store the subcode from the
    EXC_RESOURCE exceptions, this involves widening to 64-bits the code and
    subcode passed to the writer. The upper 32 bits of the code are now set in
    the minidump's exception_flags field (vs the lower 32 bits for all other
    exceptions). Additionally the exception type, code and subcode are now
    stored in the exception_information array like Crashpad does. This preserves
    the entirety of the data that came with the exception.
  • The stackwalker has been modified to print out these type of exceptions as
    well as the resource type and flavor.

This also fixes a couple of typos in the previous patch we applied to

Assignee: nobody → gsvelto
Depends on: 1725154

Besides adding EXC_GUARD to the list of exceptions the exception handler
listens to and modifying the minidump processor to interpret the exception
correctly this patch introduces a unit-test that crashes with an EXC_RESOURCE

Information about the exception itself is available here:

Additional flavors for the exception are documented here:

Last but not least the undocumented API that generates these exceptions and
which we use in the unit-test was inferred from this header:

Depends on D122229

Comment on attachment 9235838 [details]
Bug 1724368 - Add support for catching and processing EXC_GUARD exceptions on macOS r=KrisWright

Revision D122374 was moved to bug 1724388. Setting attachment 9235838 [details] to obsolete.

Attachment #9235838 - Attachment is obsolete: true
Pushed by
Add support for catching and processing EXC_RESOURCE exceptions on macOS r=KrisWright
Flags: needinfo?(gsvelto)
Pushed by
Add support for catching and processing EXC_RESOURCE exceptions on macOS r=KrisWright
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 93 Branch

Botched patch, re-landed fine.

Flags: needinfo?(gsvelto)
Blocks: 1727636
You need to log in before you can comment on or make changes to this bug.