Skip to content

fix(v8): align internal::Isolate storage to the API pointer size#226

Merged
toyobayashi merged 1 commit into
toyobayashi:mainfrom
Brooooooklyn:fix/v8-isolate-alignment
Jul 17, 2026
Merged

fix(v8): align internal::Isolate storage to the API pointer size#226
toyobayashi merged 1 commit into
toyobayashi:mainfrom
Brooooooklyn:fix/v8-isolate-alignment

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Contributor

A one-line alignment fix, split out of the original branch so it can be reviewed on its own.

v8::internal::Isolate stored its data as a plain char[1024] (alignof 1), while Internals::GetRootSlot reads it through internal::Address*. The static instance in Isolate::GetCurrent() therefore only happened to be 8-aligned on wasm64; the enlarged v8_hello_world test binding shifted the data segment so it landed on a 4-aligned address, and the first ReturnValue::Get() root load trapped under SAFE_HEAP=1 with Aborted(alignment fault).

Declaring the buffer alignas(kApiSystemPointerSize) makes correctness no longer depend on surrounding layout.

Verified: reproduced the exact CI stack locally (emsdk 6.0.2, MEMORY64=1 Debug); after the fix v8_hello_world passes on both wasm64 and wasm32 emscripten builds.

v8::internal::Isolate stored its data as plain char[1024] (alignof 1),
while Internals::GetRootSlot reads it through internal::Address*. The
static instance in Isolate::GetCurrent() therefore only happened to be
8-aligned on wasm64; the enlarged v8_hello_world test binding shifted
the data segment so it landed on a 4-aligned address, and the first
ReturnValue::Get() root load trapped under SAFE_HEAP=1 with
"Aborted(alignment fault)". Declare the buffer
alignas(kApiSystemPointerSize) so correctness no longer depends on
surrounding layout.

Verified: reproduced the exact CI stack locally (emsdk 6.0.2, MEMORY64=1
Debug); after the fix v8_hello_world passes on both wasm64 and wasm32
emscripten builds.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T34fMrYCf2V13Mg8BKmnda
@toyobayashi
toyobayashi merged commit 95bcd7d into toyobayashi:main Jul 17, 2026
6 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.

2 participants