Skip to content

Embind problems with val::as<T>() in wasm32 with MAXIMUM_MEMORY=4GB #19968

Closed
@pavshen

Description

@pavshen

There is a problem with raw pointers previously returned from embind-wrapped C++ functions by val(ptr) and structs embind-registered as value_object used later as in-parameters of type val of embind-wrapped C++ functions. Their conversion from val to native types by val::as<T>() inside the C++ function produces garbage in case of memory locations above 2GB (in raw pointer when its $$.ptr is negative; as for value_object, I don't know when). On the other hand, when they are used in functions with parameters of their native types without the usage of val they are marshaled OK. The same is with JS string literals passed as val and converted with val::as<std::string>().

(I need to pass them as val in order to support variable-type and nullable parameters).

I thought #19755 would fix this, but the problem still exists.

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.44 (bec42dac7873903d09d713963e34020c22a8bd2d)
clang version 17.0.0 (https://github.com/llvm/llvm-project a8cbd27d1f238e104a5d5ca345d93bc1f4d4ab1f)
Target: wasm32-unknown-emscripten
Thread model: posix

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions