Repository navigation
Conversation
fx exports its own C main, so Zig's start code never attached its segfault handler, and a segfault ended fx with no message and no crash report. main now sets up the signal stack and attaches the handler, as Zig's start code does. The handler calls root.debug.handleSegfault, which saves a crash report like a panic does, with error "signal" and a message such as "Segmentation fault at address 0x1234". It then calls Zig's default handler, which prints the signal and a stack trace and aborts. This covers SIGSEGV, SIGBUS, SIGILL, and SIGFPE.
Brings in the crash handler's new save, which removes the temp path and creates it as a new 0600 file, and the creation of ~/.fx. The tests from #2139 now pass the error name that this branch adds to saveRecord.
Release builds are stripped, so Zig's segfault handler prints the signal and its address and says that stack tracing is disabled. The comments now say a stack trace prints only in builds with debug info. The two signal record tests share one setup helper.
handleSegfault now calls claimSave, the shared name for the same check on the same flag, so a segfault after a saved full report also keeps it.
A crash signal ends in abort, so the system crash report no longer points at the fault, and a release build prints no stack trace. The saved message now holds the program counter and its offset from handleSegfault, which an unstripped build of the same commit can map to a line. A comment notes that a signal sent with kill has no fault address, so the saved address is then the sender's ids. The e2e test also checks the SIGABRT exit, and the module's comments cover segfaults.
Panics and crash signals now go through one saveOnce gate, which claims the save and writes through #2139's folder-descriptor save, so a crash signal also prints the saved or not-saved line and keeps a saved full report.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mainnever attached Zig's segfault handler.~/.fx/diagnostics/last-crash.jsonl, with errorsignaland a message such asSegmentation fault at address 0x1234 (pc 0x..., handleSegfault+0x...), and printsfx: crash report saved to <path>orfx: crash report not saved. The program counter and its offset let an unstripped build of the same commit map the fault to a line, since the abort hides it from the system crash report. The next/traceincludes it, under the same 24-hour rule as other crash reports. Zig's default handler only prints, and that text is gone once the terminal closes, so the saved report is what a user can still send after reopening fx.Check findings
fuzz-reached: the four targets in changed files (agents_menu_selection,trace_record_text,trace_review_records,subagent_task_line) each ran 60 seconds with statusok.concurrency-added: the signal stack and segfault handler setup inmain. A Thread Sanitizer run on this branch (run 44972802102, at 364d286) has the same 5 warnings asmain's latest nightly run, and none namessrc/main.zigorcrash_panic.zig. The later merges from Save a crash report when fx stops on an error or a panic #2139 add no threads or locks.Docs: vercel-labs/fx-web#350
Stacked on #2139.