Skip to content

Isomalloc: fix macOS 26+ segfaults - #3996

Merged
ritvikrao merged 3 commits into
charmplusplus:mainfrom
nilsvu:fix_isomalloc_probe
Sep 29, 2026
Merged

ritvikrao merged 3 commits into
charmplusplus:mainfrom
nilsvu:fix_isomalloc_probe

Conversation

@nilsvu

@nilsvu nilsvu commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

Fixes #3995. This fix was suggested by Claude. I don't have enough experience with this part of the code to properly review it, but it did fix the random segfaults that I was encountering on macOS, so I thought I'd at least show you the potential fix. Please feel free to either merge it, merge it with changes, or discard this PR.

bad_location() probed candidate addresses with mmap(..., MAP_FIXED), which
silently replaces whatever is mapped there. On macOS 26 the system
allocator's zones lie in the range that find_largest_free_region() probes,
so the probe unmapped live heap memory and every Charm++ program crashed a
few percent of the time.

Add call_mmap_probe(), which never replaces an existing mapping:
MAP_FIXED_NOREPLACE on Linux, MAP_FIXED | MAP_EXCL on FreeBSD, and a
hint-only mmap elsewhere. bad_location() unmaps whatever the probe returned
and treats a returned address that differs from the hint as "in use".

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@lvkale lvkale self-assigned this Sep 29, 2026
@ritvikrao
ritvikrao self-requested a review September 29, 2026 14:45
@ritvikrao
ritvikrao merged commit 7cc5894 into charmplusplus:main Sep 29, 2026
23 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.

Random segfaults with isomalloc on macOS 26+

4 participants