Skip to content

Commit 5676192

Browse files
committed
gh-128627: Emscripten: Fix address calculation for wasm-gc trampoline
We need to divide the entire memory address by 4, not just the base address.
1 parent 6ff8f82 commit 5676192

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Python/emscripten_trampoline.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,15 @@ addOnPreRun(() => {
154154
let ptr = 0;
155155
try {
156156
const mod = new WebAssembly.Module(code);
157-
const inst = new WebAssembly.Instance(mod, {e: {t: wasmTable}});
157+
const inst = new WebAssembly.Instance(mod, { e: { t: wasmTable } });
158158
ptr = addFunction(inst.exports.f);
159-
} catch(e) {
159+
} catch (e) {
160160
// If something goes wrong, we'll null out _PyEM_CountFuncParams and fall
161161
// back to the JS trampoline.
162162
}
163163
Module._PyEM_CountArgsPtr = ptr;
164-
const offset = HEAP32[__PyEM_EMSCRIPTEN_COUNT_ARGS_OFFSET/4];
165-
HEAP32[__PyRuntime/4 + offset] = ptr;
164+
const offset = HEAP32[__PyEM_EMSCRIPTEN_COUNT_ARGS_OFFSET / 4];
165+
HEAP32[(__PyRuntime + offset) / 4] = ptr;
166166
});
167167
);
168168

0 commit comments

Comments
 (0)