8000 Linux: handle stack guards protected via MADV_GUARD_INSTALL by schopin-mozilla · Pull Request #245 · rust-minidump/minidump-writer · GitHub
[go: up one dir, main page]

Skip to content

Linux: handle stack guards protected via MADV_GUARD_INSTALL - #245

Merged
schopin-mozilla merged 4 commits into
rust-minidump:mainfrom
schopin-mozilla:stack-guard-regions
Oct 14, 2026
Merged

schopin-mozilla merged 4 commits into
rust-minidump:mainfrom
schopin-mozilla:stack-guard-regions

Conversation

@schopin-mozilla
Copy link
Copy Markdown
Collaborator

The recent glibc releases have changed the way they allocate guard regions. Instead of a separate mapping, they use a kernel hint that doesn't show up in the procmaps data.

Closes #244

@schopin-mozilla
schopin-mozilla force-pushed the stack-guard-regions branch 2 times, most recently from c758212 to 6e32ab0 Compare October 8, 2026 10:01
@schopin-mozilla
Copy link
Copy Markdown
Collaborator Author

To clarify (and justify the number of commits), there's actually two bugs at play here:

  • We're failing to copy over the thread stack because we're running into the guard page at the end of the range. That's actually a recent regression of Isolated Processes 19: Integrate remote backend #219, so it hasn't reached Firefox yet.
  • When querying stack info, we have some code to take into account the fact that the stack pointer might have landed into its guard page, typically in case of stack overflow. However, that code does'nt know either about this new way of creating guard pages, which this PR fixes. That bug is actually present in Firefox.

Also, regarding the code, I leaned on Claude rather heavily for this one, notably for the tests.

Comment thread src/bin/test.rs Resolved
Comment thread src/bin/test.rs Resolved
Comment thread tests/linux_minidump_writer.rs Resolved
Comment thread src/bin/test.rs Resolved
Comment thread src/linux/minidump_writer/mod.rs Resolved
Comment thread tests/linux_minidump_writer.rs Resolved
Comment thread tests/linux_minidump_writer.rs Resolved
Comment thread tests/linux_minidump_writer.rs Resolved
Comment thread tests/linux_minidump_writer.rs Resolved
Comment thread tests/ptrace_dumper.rs Resolved
In recent glibc (>= 2.42), guard pages use the MADV_GUARD_INSTALL
mechanism which isn't reflected in procmaps, so some stacks are merged
together in a single mapping, and reading that entire mapping fails due
to some pages within it being guarded.

Instead, we take another approach: we know where the stack starts, so we
just read from there up until we can't anymore, which would be our guard
page.

Fixes rust-minidump#244
< 8000 div class="d-flex flex-md-row flex-column">
More functions to be used later on, with only one small observable
effect: when get_stack_info can't find the end of the guard area, it now
errors out rather than return the last visited page, which would
inevitably trigger a failure down the road.
As it turns out, just because a page permissions tell you it's readable
doesn't actually mean it is. You can madvise() the kernel to segfault on
that page via MADV_GUARD_INSTALL, so we actually try and read stuff to
be sure that we're safe.
@gabrielesvelto gabrielesvelto left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, just left a nit

Comment thread tests/linux_minidump_writer.rs Resolved
This should allow us a decent coverage of the various glibc quirks over
time. That would have caught the madvise thing.
@schopin-mozilla
schopin-mozilla merged commit 59aad8d into rust-minidump:main Oct 14, 2026
20 checks passed
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.

Linux: dump fails with EIO when a thread stack mapping runs into a MADV_GUARD_INSTALL guard page (glibc ≥ 2.42)

2 participants

0