Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[embind] Only allow class types for unique_ptr bindings. #21637

Merged
merged 1 commit into from
Apr 8, 2024

Conversation

brendandahl
Copy link
Collaborator

As pointed out by #21625, when using unique_ptr's with primitive types the raw pointer was being passed between wasm and JS, but it was using the underlying type (e.g. char, int, etc) to convert the value. This means the pointer was truncated to a char at the boundary.

Embind doesn't allow pointers or references to primitive types so it doesn't make sense to allow a unique_ptr for these types either.

Copy link
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with 2gb mode added to test_embind (-sINITIAL_MEMORY=2200mb -sGLOBAL_BASE=2gb)

As pointed out by emscripten-core#21625, when using unique_ptr's with primitive types the
raw pointer was being passed between wasm and JS, but it was using the
underlying type (e.g. char, int, etc) to convert the value. This means the
pointer was truncated to a char at the boundary.

Embind doesn't allow pointers or references to primitive types so it doesn't
make sense to allow a unique_ptr for these types either.
@brendandahl brendandahl merged commit 5d688ec into emscripten-core:main Apr 8, 2024
29 checks passed
impact-maker pushed a commit to impact-maker/emscripten that referenced this pull request Apr 11, 2024
…core#21637)

As pointed out by emscripten-core#21625, when using unique_ptr's with primitive types the
raw pointer was being passed between wasm and JS, but it was using the
underlying type (e.g. char, int, etc) to convert the value. This means the
pointer was truncated to a char at the boundary.

Embind doesn't allow pointers or references to primitive types so it doesn't
make sense to allow a unique_ptr for these types either.
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.

None yet

2 participants