-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix ABI for raw pointers #3655
fix ABI for raw pointers #3655
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this definitely looks like a bug to me:
wasm-bindgen/src/convert/impls.rs
Lines 208 to 242 in 46f52e9
impl<T> IntoWasmAbi for *const T { | |
type Abi = u32; | |
#[inline] | |
fn into_abi(self) -> u32 { | |
self as u32 | |
} | |
} | |
impl<T> FromWasmAbi for *const T { | |
type Abi = u32; | |
#[inline] | |
unsafe fn from_abi(js: u32) -> *const T { | |
js as *const T | |
} | |
} | |
impl<T> IntoWasmAbi for *mut T { | |
type Abi = u32; | |
#[inline] | |
fn into_abi(self) -> u32 { | |
self as u32 | |
} | |
} | |
impl<T> FromWasmAbi for *mut T { | |
type Abi = u32; | |
#[inline] | |
unsafe fn from_abi(js: u32) -> *mut T { | |
js as *mut T | |
} | |
} |
@Liamolucko would you mind confirming this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I agree this is a bug. Thanks!
Awesome! Thanks so much for this quick turn around and for merging this so quickly 🙌 Is there a chance we can get this released? |
See #3530. |
👋 Hello from Stackblitz
We've noticed very buggy behavior when our Rust code requires a sizable amount of memory (above 2 GiB!). I've traced it back to
__wbindgen_malloc
returning negative pointers (!!), which screams "i32
overflow" 😬From what I can gather, changing the
WasmDescribe
impl. for raw pointers (so they followu32
ABI conventions instead ofi32
's) should fix it. I've added areferences
test towasm-bindgen-cli
, not sure how appropriate/useful is.