Skip to content

Conversation

@mszabo-wikia
Copy link
Contributor

When built with jemalloc, HHVM defines several custom arenas that allocate from well-known address ranges. This historically was gated behind the Meta-specific USE_JEMALLOC_EXTENT_HOOKS define, which was removed in early September by upstream. PIE builds of HHVM are broken as a result since the entire arrangement appears to rely on at least the translation cache being in a predefined memory location, which PIE ipso facto precludes.

So, have the ENABLE_PIE build flag define an ENABLE_PIE define and a use_position_dependent_jemalloc_arenas constexpr to disable the problematic behavior. Reinstate and use the previous limited arena setup for PIE builds where only the low arena exists and is backed by sbrk(2) rather than mmap, as it was prior to D78567435.

PIE also means we can't use 32-bit SmallPtrs for things like function pointers, so define FULLPTR_FOR_BUILTINS in PIE builds and use emitLdPackedPtr when referring to them in the JIT rather than 32-bit-only instructions.

@meta-codesync
Copy link

meta-codesync bot commented Nov 12, 2025

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this in D86880066. (Because this pull request was imported automatically, there will not be any future comments.)

When built with jemalloc, HHVM defines several custom arenas
that allocate from well-known address ranges. This historically
was gated behind the Meta-specific `USE_JEMALLOC_EXTENT_HOOKS` define,
which was removed in early September by upstream. PIE builds of HHVM
are broken as a result since the entire arrangement appears to
rely on at least the translation cache being in a predefined memory
location, which PIE ipso facto precludes.

So, have the `ENABLE_PIE` build flag define an `ENABLE_PIE` define
and a `use_position_dependent_jemalloc_arenas` constexpr to disable
the problematic behavior. Reinstate and use the previous limited
arena setup for PIE builds where only the low arena exists and is
backed by sbrk(2) rather than mmap, as it was prior to D78567435.

PIE also means we can't use 32-bit SmallPtrs for things like function
pointers, so define `FULLPTR_FOR_BUILTINS` in PIE builds and use
`emitLdPackedPtr` when referring to them in the JIT rather than
32-bit-only instructions.
@facebook-github-bot
Copy link
Contributor

@mszabo-wikia has updated the pull request. You must reimport the pull request before landing.

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.

2 participants