8000 Enable support for FreeBSD by G36maid · Pull Request #183 · rust-minidump/minidump-writer · GitHub
[go: up one dir, main page]

Skip to content

Enable support for FreeBSD - #183

Open
G36maid wants to merge 8 commits into
rust-minidump:mainfrom
G36maid:freebsd
Open

G36maid wants to merge 8 commits into
rust-minidump:mainfrom
G36maid:freebsd

Conversation

@G36maid
@G36maid G36maid commented May 15, 2026 •
Copy link
Copy Markdown
Contributor

CLOSES #162

Adds FreeBSD (x86_64) support, reworked onto the post-Isolated-Processes architecture.

All process state goes through a ProcessInspector trait (src/freebsd/process_inspection/), same shape as the Linux implementation: the writer holds a Box<dyn ProcessInspector> and nothing below it touches ptrace/sysctl directly. The local inspector uses PT_IO for memory reads, PT_ATTACH/PT_DETACH for tracing, PT_SUSPEND/PT_RESUME for per-thread control, PT_GETREGS/PT_GETFPREGS for registers, and kinfo_getvmmap/KERN_PROC_AUXV for maps and auxv.

A few FreeBSD-specific things worth knowing:

  • The main executable's name is recovered from AT_EXECPATH when the binary has been deleted from disk (FreeBSD's kinfo_getvmmap reports no path for deleted files, unlike Linux's (deleted) suffix in /proc/pid/maps).
  • KVME_TYPE_GUARD and KVME_TYPE_DEAD mappings are filtered from the vm map, mirroring how MADV_GUARD_INSTALL pages are invisible on Linux.
  • Guard mappings, linker reservations, and empty pages between segments are handled in the maps reader's merge logic, ported from the Linux equivalent.

src/freebsd/module_reader.rs is a port of the Linux ELF machinery. Sharing it between platforms requires splitting ModuleReaderError (which has Linux-specific variants); I'd like to do that as a follow-up rather than expanding this PR further.

CI runs the full test suite on FreeBSD 14.4 and 15.0 (MSRV 1.90.0) via vmactions/freebsd-vm.

Follow-ups: split the backend into crates/ + remote support, FreeBSD branch for crash-context (unblocks the zed-on-FreeBSD chain, EmbarkStudios/crash-handling#108), deduplicate the ELF module reading, dso_debug, i386/aarch64.

@G36maid G36maid changed the title Enable support for freeBSD Enable support for FreeBSD May 15, 2026
@G36maid
G36maid force-pushed the freebsd branch 7 times, most recently from 12c9339 to 2a46b57 Compare May 16, 2026 10:07
@gabrielesvelto
Copy link
Copy Markdown
Contributor

Thank you for this work, FreeBSD support in this crate together with some upstream work I'm making in Firefox would make it possible to have proper crash reporting enabled on the platform. It's worth mentioning that we're refactoring the interfaces we use to read from a process to make room from a proxy'd process reader which we need on Android. Check the changes in both the pending and already merged PRs that are called "Isolated Processes X: ...". Those changes are largely mechanical and do not affect the logic, just where some pieces live and how they're accessed.

@G36maid
G36maid commented May 19, 2026
Copy link
Copy Markdown
Contributor Author

Thanks for the quick response! It's great to know this work could help.

I'm currently running some bare-metal testing on FreeBSD — things are looking good so far. I'd be happy if you'd like to start reviewing this PR while I finish up the testing.

I've also taken a peek at the Isolated Processes PR series (#/174–#/182). Once the testing is done and this PR is in a good state, I plan to follow up by adapting ProcessInspector for FreeBSD to align with the new architecture.

One question: would you prefer I do it as a follow-up PR after this one lands, or fold it in here? I 'd prefer to keep them separate — this PR is already fairly large. Happy to go either way though.

@gabrielesvelto
Copy link
Copy Markdown
Contributor

One question: would you prefer I do it as a follow-up PR after this one lands, or fold it in here? I 'd prefer to keep them separate — this PR is already fairly large. Happy to go either way though.

It's fine to make that a follow up if it makes life easier for you.

@G36maid
G36maid force-pushed the freebsd branch 5 times, most recently from f60892f to 99ca085 Compare May 26, 2026 16:44
@G36maid
G36maid commented Jun 13, 2026
Copy link
Copy Markdown
Contributor Author

Sorry for the delay over the past few weeks. I was caught up with some unexpected interviews and tests, so I didn't have time to push this PR forward.

I have some free time now, so I'll review where I left off and pick this back up.

@gabrielesvelto
Copy link
Copy Markdown
Contributor

np, I've been very busy myself and I also need to spin up a FreeBSD VM to test

@gabrielesvelto
Copy link
Copy Markdown
Contributor

Quick update: I still haven't found the time to spin up a FreeBSD VM because I've been constantly putting out fires at work and churning through other reviews. I should have some time the next week to look into this, or at the absolute worst at the end of the month. I wish I could be more responsive to contributions because they genuinely interest me and I'm always happy to receive them but work has been absolutely hectic leaving me with very little time and energy for anything else.

@G36maid
G36maid commented Jul 8, 2026
Copy link
Copy Markdown
Contributor Author

No worries at all! That actually works out because I haven't finished organizing and polishing up my side of the PR yet either.

@gabrielesvelto
Copy link
Copy Markdown
Contributor

Sorry again for the huge delay here, the good news is we're done messing with the crate interface to deal with remote dumpers so now would be a good time to rebase this as the crate's interface and internals should remain stable.

@G36maid
G36maid commented Oct 20, 2026
Copy link
Copy Markdown
Contributor Author

Thanks for the heads-up! Rebased onto main — some small conflicts. The FreeBSD side needs a bit of rework to fit the new trait (our reader currently owns the ptrace logic directly), I'll push the updated branch once that's done.

@G36maid
G36maid force-pushed the freebsd branch 2 times, most recently from 794d69e to 34e6513 Compare October 21, 2026 11:47
@G36maid
G36maid marked this pull request as ready for review October 21, 2026 13:49
@G36maid
G36maid force-pushed the freebsd branch 3 times, most recently from 6ec5404 to 1a32551 Compare October 21, 2026 19:33
@G36maid
G36maid commented Oct 21, 2026
Copy link
Copy Markdown
Contributor Author

All set and marked ready for review!

Rebased onto the latest main with the ProcessInspector refactor in place. Verified on FreeBSD action with CI on my fork.

I'm currently prototyping and testing the follow-ups on my end. Take your time with the review, and let me know if anything needs tweaking!

@gabrielesvelto
Copy link
Copy Markdown
Contributor

Another quick update: I'm wrapping up some stuff downstream in Firefox, then I'll cut a new release of this crate and then I'll proceed with review & merging this. Again sorry for the delay but it's a bit of a hectic period because we have at least three major projects within Firefox crash reporting machinery that are being finished at the same time and some days I'm doing reviews almost non-stop.

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.

Please add support for FreeBSD

2 participants

0