Skip to content

feat: Sentry native crash backend#1433

Merged
mujacica merged 143 commits intomasterfrom
feat/sentry_native_backend
Mar 6, 2026
Merged

feat: Sentry native crash backend#1433
mujacica merged 143 commits intomasterfrom
feat/sentry_native_backend

Conversation

@mujacica
Copy link
Contributor

  • Sentry native crash backend
  • Out-of-process daemon/handler
  • MacOS/Android/Windows/Linux support
  • Integration with external crash reporter
  • IPC/SHM/Signaling multi-platform implementation
  • Minidump writers for all platforms
  • In-process option (process_crash function)
  • Different options for Minidump sizes
  • Full sentry-codebase integration
  • Sentry logger integration
  • Sentry debug-flags integration

@mujacica
Copy link
Contributor Author

@sentry review

1 similar comment
@mujacica
Copy link
Contributor Author

@sentry review

@mujacica mujacica force-pushed the feat/sentry_native_backend branch from 216b3cd to e4cd98c Compare January 15, 2026 10:28
@mujacica
Copy link
Contributor Author

@sentry review

@mujacica
Copy link
Contributor Author

@cursor review

@mujacica
Copy link
Contributor Author

@cursor review

@mujacica mujacica force-pushed the feat/sentry_native_backend branch from d634773 to eb77775 Compare January 15, 2026 19:37
@mujacica
Copy link
Contributor Author

@sentry review

@mujacica mujacica force-pushed the feat/sentry_native_backend branch from d46d50a to d38b5e1 Compare January 17, 2026 08:10
@mujacica mujacica marked this pull request as ready for review January 17, 2026 11:50
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@mujacica mujacica force-pushed the feat/sentry_native_backend branch from d33258f to 71ea60d Compare January 20, 2026 10:01
@mujacica mujacica changed the title (POC) feat: Sentry native crash backend feat: Sentry native crash backend Jan 20, 2026
@github-actions
Copy link

github-actions bot commented Jan 20, 2026

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 80a09db

@linear
Copy link

linear bot commented Feb 5, 2026

@mujacica mujacica force-pushed the feat/sentry_native_backend branch from 79d2b05 to a6af7d6 Compare February 5, 2026 09:54
mujacica and others added 15 commits March 5, 2026 09:10
…ro stack_start_out on alloc failure

- current_offset was uint32_t, making the > UINT32_MAX check always
  false. Widening to uint64_t lets the guard actually detect overflow.
- write_thread_stack now zeros *stack_start_out on malloc failure,
  matching the macOS counterpart.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… structs

The previous commit widened current_offset to uint64_t in the base
struct but not in the Linux/macOS platform structs, causing a layout
mismatch that corrupted the crash_ctx pointer on every write_data call.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…permissions

- aarch64 Linux: use struct field access (uctx->uc_mcontext.regs[i],
  .sp, .pc) instead of raw pointer indexing that skipped fault_address,
  causing every register value to be shifted by one
- Windows: request PROCESS_DUP_HANDLE when opening crashed process in
  FULL mode, needed for MiniDumpWithHandleData

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rning on aarch64

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- write_data: seek back on partial write to keep fd position in sync
  with current_offset
- write_module_list_stream: bail early if initial module list write
  fails (rva==0) to prevent patching into header area
- thread_context.size: only set non-zero when write_thread_context
  succeeds, preventing invalid location descriptors pointing at
  offset 0 (Linux and macOS, 5 locations)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…g write sync

- Update thread_context.size after ptrace re-write in Linux minidump
  writer so it stays consistent with the RVA
- Validate bytes_read matches requested size in macOS read_task_memory
  to detect partial reads
- Seek back on partial padding write in write_data to keep fd position
  in sync with current_offset

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- macOS SMART mode now only captures the crash-address region instead of
  all readable+writable regions, matching Linux behavior and the ~5-10MB
  target documented in the API
- Cap per-region size to 4MB (was 64MB) to match Linux
- Add UINT32_MAX overflow check in write_data to prevent silent RVA
  truncation when minidumps exceed 4GB in FULL mode

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix minidump OS platform IDs to match Breakpad MDOSPlatform standard:
  Linux 0x8201, macOS 0x8101, iOS 0x8102, Android 0x8203. Previous
  values (0x8000-0x8003) caused server-side misidentification.
- Fix write_thread_stack to find non-main thread stacks by falling back
  to anonymous rw-p mappings when no named [stack] mapping is found.
  On Linux, only the main thread stack is labeled [stack] in
  /proc/pid/maps; all other thread stacks are anonymous.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…CE order

- Guard malloc(0) when module_count is zero to avoid implementation-
  defined NULL return being treated as allocation failure
- Add MiscInfoStream (with process_id) to the full macOS minidump path,
  matching the fallback path and ensuring consistent server-side
  processing
- Move _XOPEN_SOURCE definition before all system header includes so
  ucontext_t is properly exposed on strict POSIX systems

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace mach_thread_self() with pthread_mach_thread_np(pthread_self())
  in crash signal handler to avoid leaking a Mach port reference
  (mach_port_deallocate is not async-signal-safe)
- Fix x86_64 FPU instruction/data pointer truncation: split 64-bit
  fpregs.rip/rdp across error_offset+error_selector and
  data_offset+data_selector per FXSAVE format
- Copy fpregs.fop to error_opcode on Linux (was missing, already done
  on macOS)
- Copy __fpu_cs/__fpu_ds to error_selector/data_selector on macOS
- Always write 5 streams on Linux (matching macOS), using an empty
  memory list for STACK_ONLY instead of omitting it

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Condition stack_size_out and mem->memory.size on write_data returning a
non-zero RVA. Previously, rva=0 with size>0 would cause minidump
parsers to read from offset 0 (the header), producing corrupt results.
Fixed in both Linux and macOS writers for stack and memory list streams.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Skip segments with initprot=0 and maxprot=0 (__PAGEZERO) when
  calculating module size on macOS. __PAGEZERO has vmsize=4GB on 64-bit,
  which inflated size_of_image and caused overlapping module ranges in
  minidumps.
- Guard thread stack descriptor in macOS fallback path against
  write_data failure, matching the pattern used elsewhere.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mujacica mujacica force-pushed the feat/sentry_native_backend branch from aa9763c to efa6859 Compare March 5, 2026 08:11
The idle threshold was a workaround for the broken snapshot-and-compare
approach. The 5s cond_wait_timeout is the batching window — when it
fires and there are items, flush them. This matches the original master
behavior and removes the last_enqueue_ms field and its atomic
bookkeeping.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

- CHANGELOG: note the native backend feature as experimental and under
  active development
- CMakeLists.txt: emit CMake WARNING when selecting the native backend
- sentry_backend_native.c: log SENTRY_WARN at startup
- README: add native backend to the SENTRY_BACKEND options list with
  (Experimental) tag

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Only accept native-endian Mach-O magic. Byte-swapped binaries (MH_CIGAM*)
cannot be loaded on the current platform, so accepting them without
swapping all header fields would cause corrupt reads.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mujacica and others added 2 commits March 5, 2026 11:41
Co-authored-by: J-P Nurmi <jpnurmi@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 9 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@mujacica mujacica merged commit 0b78a70 into master Mar 6, 2026
50 checks passed
@mujacica mujacica deleted the feat/sentry_native_backend branch March 6, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants