skip to content

When a note-taking phone app crashes, what must its crash report carry, and how is it recorded while the process is dying?

level: middleimportance: should knowfreq 48%

answer

  1. the process is already broken
  2. write to disk, never the network
  3. every thread, not just one
  4. build, OS, model, memory, disk
  5. upload on the next launch

basics

~20 s

Every thread's stack, the exact build, OS version, device model, free memory and disk, and foreground or background. A handler in the app writes this to a file as the process dies; the next launch uploads it.

solid answer

~50 s

A managed exception reaches an uncaught-exception handler; a native fault arrives as a fatal signal in a process whose heap and locks may already be corrupt. Either way the handler does the minimum: it fills a buffer allocated at launch, writes it to a file opened at launch — no new memory, no locks, no network — then calls any previously installed handler and lets the process die. On the next launch the app uploads the file in the background and deletes it once the server acknowledges it. The record carries every thread's stack with the crashing one marked, the exception or signal, each binary's build identifier and load address, app version and build number, OS version, device model, free memory and disk, foreground or background, time since launch, and the app's breadcrumbs and custom keys.

code

json · 19 lines
json
{
  "report_id": "5f0c9a1e-6b7d-4c1a-9e43-2d8f1b7a0c55",
  "crashed_at": "2026-10-07T21:14:03.120Z",
  "kind": "native_signal",
  "signal": "segmentation_fault",
  "app": { "version": "4.12.0", "build": "41207" },
  "binaries": [
    { "name": "app", "build_id": "4c2a9f0e7d1b4e83a6c5f2091b7d3e58", "load_address": "0x10459c000" },
    { "name": "richtext_engine", "build_id": "9a1f02c4d8e7b6a5f4e3d2c1b0a99887", "load_address": "0x10a2f0000" }
  ],
  "device": { "model": "phone-model-x", "os_version": "16.1", "cpu": "arm64" },
  "resources": { "free_memory_mb": 212, "free_disk_mb": 38 },
  "state": { "foreground": false, "screen": "none", "seconds_since_launch": 41 },
  "threads": [ { "index": 0, "crashed": false, "frames": ["..."] }, { "index": 7, "name": "sync", "crashed": true, "frames": ["..."] } ],
  "breadcrumbs": [ { "type": "sync_step", "step": "merge", "outcome": "conflict", "notes": 3 } ],
  "keys": { "sync.state": "merging", "flag.new_editor": "on" },
  "install_id": "b1c7e2a0-4f3d-4e8a-a9d2-7c6b5e4f3a21",
  "session_id": "0d9e8f7a-1b2c-4d3e-8f4a-5b6c7d8e9f01"
}

go deeper

for a junior

Recall the fields a crash report needs — every thread, the exact build, OS, device, memory, disk, foreground or background — and that it is saved first and uploaded later.

for a middle

Explain why a native fault leaves the process unsafe, what the handler may still do, and why it writes to a file opened at launch rather than calling the network.

for a senior

Show the traps in a real app: handlers that replace each other, crashes before the reporter is armed, background crashes, and reports uploaded by a newer version days later.

for a principal

Decide which component owns crash capture across teams and SDKs, how early it must run, and what each report may contain, weighing diagnostic value against what the store disclosure must declare.

## Two ways a mobile process dies A **crash** is an unexpected exit: the code hit something it could not handle and the process ended. On a phone it reaches the app in one of two forms: - an uncaught **managed exception** in code running on a virtual machine or runtime — the runtime calls an **uncaught-exception handler** before the process ends; - a **native fault** in compiled code — a bad pointer, an illegal instruction, an abort — which the OS delivers as a **fatal signal** to a handler the app installed. Either can happen while the app is in the background: a home-screen widget refresh or a background sync can crash a note-taking app the user is not even looking at. Those crashes count, and the report must say the app was in the background. ## What the handler may do while the process dies A native fault often means memory is already corrupt: the heap may be half-way through an update and another thread may hold a lock. The handler runs in that state, so it must only do things that cannot block, allocate or touch shared state: 1. **Prepare at launch**, while the process is healthy: open the report file and allocate the buffer. 2. **Capture** every thread's stack and the exception type or signal into the buffer. 3. **Copy the context** the app already holds in memory — breadcrumbs and custom keys — into the same buffer. 4. **Write** the buffer to the pre-opened file with a plain write: no network, no database, no locks, no new memory. 5. **Hand on** to the previously installed handler and let the process end, so the OS's own crash record still happens. A managed handler runs in a healthier process, but the rule is the same: write locally, then die. Anything slower risks a second crash inside the handler, or the process ending before the work finishes. ## What the report must carry | Field | Why it is needed | |---|---| | every thread's stack, crashing thread marked | the cause is often another thread holding a lock or changing shared state | | exception type or signal, fault address | separates a null dereference from an abort or an allocation failure | | each binary's build identifier and load address | symbolication against the exact build | | app version and build number | grouping and comparison per version | | OS version, device model, CPU architecture | crashes cluster on one model or one OS release | | free memory and free disk | out-of-memory paths; failed saves on a full disk | | foreground or background, current screen, time since launch | a sync crash, a launch crash and an editor crash read differently | | breadcrumbs and custom keys | how the app got there and what state it was in | | a random install id and a session id | counting the users and sessions affected | Free disk matters more than it looks in a note-taking app: a save into a full disk throws inside the database layer, and without the number the resulting crashes look random. ## Install early, install once The reporter must be armed before anything that can crash, which makes it one of the few pieces of work that belongs at the very top of the launch path; keeping the rest of that path short is separate work. Two traps follow: - **Handler replacement.** Several SDKs may each install a handler, and the last one installed wins. A handler that does not call the one before it silently disables the others. Give one component ownership and make every handler chain. - **Crashes before arming.** Code that runs before the handler is installed — static initialisers, a framework booting — crashes with no app-side report. The OS may still record it, which is one reason the store's crash figures and the app's own can disagree. ## Uploading on the next launch The saved file is sent when the app next runs: - after the first screen is up and off the main thread, so reporting never slows the launch; - compressed, retried on failure, and deleted only after the server acknowledges it; - stamped with the crash time and the build that crashed, because the next launch may be days later and may even be a newer version. A report waiting on disk is also the app's first evidence that the previous run ended badly. ## What no handler can record Some exits never reach a handler. When the OS ends a hung app, or the user closes a frozen one, the process is killed with a signal it cannot catch: nothing runs and nothing is written. Those exits need a different mechanism — markers the app leaves behind and reads at the next launch — and a report that never arrives is not evidence that nothing went wrong.

  • Why not upload the report directly from inside the crash handler?
    The process is broken: the network stack allocates memory, takes locks and needs other threads, any of which may be what failed, and the OS may end the process within moments. The phone may also be offline. A plain write to a file opened at launch is the one bounded operation, so the upload waits for the next launch, which still has the file.
  • Two SDKs in the app each install a crash handler; what goes wrong, and how do you prevent it?
    The last handler installed replaces the earlier one, and if it does not call the previous handler, the first reporter never sees a crash. Give one component ownership of crash capture, make any other handler chain to the one before it, and prove it with a deliberate test crash in a release-configured build.
  • Why should a crash report say whether the app was in the foreground?
    A background crash during sync or a widget refresh has a different cause and a different cost: the user saw nothing, but notes may be left half-merged. Separating foreground and background crashes also keeps background launches from diluting the foreground crash rate when versions are compared.

  • The crash handler can safely send the report over the network before the process exits.
  • The crashing thread's stack is all a crash report needs.
  • The app's version string alone identifies the build that crashed.
  • A crash in the background does not matter because the user never saw it.
  • Installing our own crash handler over any existing one is harmless.