emscripten-core / emscripten-core/emscripten

Can't pass 64-bit pointers from native code to native code through JS

Open
#26,625 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

**Version of emscripten/emsdk:**
`emscripten 5.0.4 "emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 5.0.4 (62e22652509fbe7a00609ce48a653d0d66f27ba5)"`

Code sample (compile with `emcc` and `-sMEMORY64=1`):
```c
#include
#include
#include

void EMSCRIPTEN_KEEPALIVE frog(uint32_t *toad) {
printf("Pointer contents: %d\n", *toad);
}

int main(void) {
uint32_t tadpole = 42;

EM_ASM("_frog($0);", &tadpole);

return 0;
}
```

This should print `Pointer contents: 42` (while with `-sMEMORY64=1` option, this causes a `TypeError: Cannot convert to a BigInt` error)

The problematic piece of code is here: https://github.com/emscripten-core/emscripten/blob/5.0.5/src/parseTools.mjs#L478 (which is still present in commit a7804eae3aefb0d174b63cdf6b3616a7cae86c27)

This notably affects miniaudio in 64-bit mode (the audio output is silent; there's no issue tracked for that bug yet though)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.