Skip to content

jemalloc-sys: always use prefixed malloc on AIX - #197

Open
tobz wants to merge 1 commit into
tikv:mainfrom
tobz:aix-prefixed-malloc
Open

tobz wants to merge 1 commit into
tikv:mainfrom
tobz:aix-prefixed-malloc

Conversation

@tobz

@tobz tobz commented Oct 30, 2026 •

Copy link
Copy Markdown

This PR adds aix to the list of targets that don't support unprefixed malloc (NO_UNPREFIXED_MALLOC_TARGETS).

When trying to use jemalloc on AIX as part of a work project, I encountered this issue and worked through it with an LLM, eventually leading to roughly the same conclusion/reproduction as has already been identified in the comments for NO_UNPREFIXED_MALLOC_TARGETS: certain standard library calls, such as std::fs::canonicalize, were allocating memory through the system allocator, and then trying to free them through jemalloc.

It seems like this could be supported by using rtl_enable as the commit message alludes to, but given that doing so requires manual intervention on behalf of the user, modifying shared objects in the process, and on the host running the application rather than the build host... it struck me as infeasible and that disallowing unprefixed mode for AIX was the simplest and most reasonable position to take.

Summary by CodeRabbit

  • Bug Fixes
    • On AIX, jemalloc now consistently uses prefixed symbols, matching its behavior on Android, DragonFly, and Apple platforms. This prevents conflicts between libc and jemalloc memory allocation that could cause std::fs::canonicalize to crash when freeing memory returned by libc’s realpath.

AIX binds libc's internal calls to malloc when libc itself is linked, and
they can't be rebound to a malloc defined in the program without rebuilding
libc with rtl_enable. With unprefixed_malloc_on_supported_platforms, code in
the executable uses jemalloc's malloc and free while libc keeps its own, so
memory crosses allocators. std::fs::canonicalize, for example, frees
realpath's result with free.

On an AIX 7 host, with jemalloc unprefixed, strdup and realpath(path, NULL)
didn't allocate from jemalloc, while malloc and free called from the
executable did, and std::fs::canonicalize segfaulted on its first call.

Add AIX to NO_UNPREFIXED_MALLOC_TARGETS, and reference IBM's documentation
of this behaviour alongside the existing Rust commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Toby Lawrence <toby@nuclearfurnace.com>
@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c6d654b8-2138-4036-9c17-99ffdbefd999
Commits

Reviewing files that changed from the base of the PR and between 2179271 and 77fff7e.

Files selected for processing: 2
  • CHANGELOG.md
  • jemalloc-sys/src/env.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

The target list now includes AIX among the platforms that use prefixed symbols. The changelog describes the allocator mismatch and std::fs::canonicalize crash associated with the previous configuration.

Changes: AIX symbol prefixing

Layer / File(s) Summary
Add AIX to prefixed-symbol targets
jemalloc-sys/src/env.rs, CHANGELOG.md
The target list adds AIX and an IBM AIX runtime-linking reference. The changelog records the allocator mismatch and canonicalize crash.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: madsmtm, busyjay

Merge Risk: Minimal · up to 77fff

The change is ready to merge; the referenced IBM documentation remains accessible and no actionable review risks remain.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "jemalloc-sys: always use prefixed malloc on AIX" matches the main change. The PR adds "aix" to NO_UNPREFIXED_MALLOC_TARGETS in jemalloc-sys/src/env.rs, so AIX builds always use prefixed mal…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "jemalloc-sys: always use prefixed malloc on AIX" matches the main change. The PR adds "aix" to NO_UNPREFIXED_MALLOC_TARGETS in jemalloc-sys/src/env.rs, so AIX builds always use prefixed malloc symbols. The changelog entry and the commit rationale (allocator mismatch causing a crash in std::fs::canonicalize) support this reading. The title names the component, the platform, and the behavior change. It omits the crash rationale, which is acceptable for a title.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files. (1 skipped: 1 unsupported.)

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ti-chi-bot

ti-chi-bot Bot commented Oct 30, 2026

Copy link
Copy Markdown

Welcome @tobz! It looks like this is your first PR to tikv/jemallocator 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant