Skip to content

postmaster: async-signal-safe frame dump in the crash handler - #100

Open
brandonros wants to merge 1 commit into
malisper:mainfrom
brandonros:fix/crash-handler-signal-safe-backtrace
Open

postmaster: async-signal-safe frame dump in the crash handler#100
brandonros wants to merge 1 commit into
malisper:mainfrom
brandonros:fix/crash-handler-signal-safe-backtrace

Conversation

@brandonros

@brandonros brandonros commented Sep 6, 2026

Copy link
Copy Markdown

`backtrace_symbols_fd()` is not async-signal-safe: on macOS it calls `dladdr()` (dyld locks), and on glibc the first `backtrace()` call `dlopen()`s libgcc_s. A fault inside the allocator or the loader then hangs the handler instead of crashing, so the process never reaches `raise()` and leaves no core file.

This writes raw frame addresses with `write(2)` into a bounds-clamped stack buffer (Linux and macOS) and leaves symbolizing to `atos` / `addr2line`. The lint-determinism allow row grows by the two extra `write(2)` sites.

Split out of the objkv series (#92) as an independent fix; it does not depend on any of it.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved crash diagnostics on Linux and macOS by including raw hexadecimal backtrace addresses from fatal-signal handlers.
    • Prevented long backtraces from being truncated when diagnostic output spans multiple writes.
    • Crash output no longer includes symbolized function names directly; addresses can be symbolized separately.

backtrace_symbols_fd() is not on the async-signal-safe list. On macOS
it calls dladdr(), which takes dyld's locks; on glibc the hazard is
backtrace()'s first call, which dlopen()s libgcc_s. A fault inside the
allocator or the loader then hangs the handler instead of crashing,
so the process never reaches raise() and leaves no core file.

Write raw frame addresses with write(2) into a bounds-clamped stack
buffer instead, on Linux and macOS, and leave symbolizing to atos /
addr2line. The lint-determinism allow row grows by the two extra
write(2) sites.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: fd23a136-a747-4025-b253-e33697ad7e17

📥 Commits

Reviewing files that changed from the base of the PR and between 4c2e49f and ad103f0.

📒 Files selected for processing (2)
  • crates/_support/seams_init/tests/lint-determinism.allow
  • crates/backend/postmaster/postmaster/src/crash_signals.rs

Included review availability: Your plan provides up to 8 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

The fatal-signal handler now emits raw hexadecimal frame addresses on Linux and macOS. It flushes buffered output across multiple writes. The lint configuration allows the additional write calls.

Changes

Crash signal backtrace output

Layer / File(s) Summary
Raw backtrace emission
crates/backend/postmaster/postmaster/src/crash_signals.rs, crates/_support/seams_init/tests/lint-determinism.allow
The handler replaces symbolized output with hexadecimal frame addresses, flushes the Writer when needed, enables macOS support, and increases the filesystem budget.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to ad103

Crash backtraces now emit raw hexadecimal frame addresses on Linux and macOS rather than symbolized frames, avoiding the unsafe symbolization call in the fatal-signal path. No merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding an async-signal-safe frame dump to the postmaster crash handler.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant