Skip to content

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

@TheComputerGuy96

Description

@TheComputerGuy96

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):

#include <emscripten.h>
#include <stdint.h>
#include <stdio.h>

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 <number> 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 a7804ea)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions