Skip to content

Conversation

@emeryberger
Copy link
Member

Summary

  • Fixes crash when using Mesh with cargo build and other programs that fork heavily
  • Adds fsync() to ensure copied data is persisted before remapping
  • Falls back to munmap + mmap when direct mmap fails with EACCES or EBADF

Test plan

  • Unit tests pass (40/40)
  • Simple Rust project builds
  • rustc-dev-guide builds
  • Complex project with dependencies builds (with -j1)

Fixes #123

🤖 Generated with Claude Code

When a child process tries to remap the arena after fork, mmap with
MAP_FIXED may fail with EACCES or EBADF on certain kernel versions
when replacing a MAP_SHARED mapping that's also mapped in the parent.

This fix:
- Adds fsync() to ensure copied data is persisted before remapping
- Falls back to munmap + mmap when the direct mmap fails with
  EACCES or EBADF

Fixes: #123

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@emeryberger emeryberger requested a review from bpowers January 18, 2026 22:50
@bpowers bpowers mentioned this pull request Jan 20, 2026
2 tasks
@bpowers bpowers closed this in #125 Jan 21, 2026
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.

Mesh crashes when used as allocator for cargo build

1 participant