-
Notifications
You must be signed in to change notification settings - Fork 18k
wasm/misc: getInt64 won't work in JavaScript #29786
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
Comments
I can not reproduce this issue. The code
works fine for me. Yes, it is known that getInt64 only returns a precision of 53 bits. I don't see how this is related to your crash. Please elaborate. |
OP is writing a webpack loader for Go. @xtuc - Could you please mention the entire steps for bundling the file through your loader and checking it in the browser ? |
I mentioned the the Webpack loader for context, but it's not relevant. The issue is that passing an out-of-range Integer throws in JavaScript. For example the crash described here does something like: const b = new ArrayBuffer(254);
const ptr = 2 ** 55;
const len = ptr + 4;
new Uint8Array(b, ptr, len); Throws with I can reproduce it using the example in the repo https://github.com/wasm-tool/golang/tree/master/example. That said, I'm wondering why I'm having such high addresses. Please let me know if I can provide more informations/tests. |
Please provide a test that can reproduce the issue with I took a quick look at your code and my best guess is that |
I pretty sure I won't be able to reproduce the issue using the Go compiler itself and my example (Go run returns However, the issue could theoretically occur in real world, if a program has adresses > Note that I opened the issue because of the potential usage of invalid numbers in JavaScript. Edit: while you are taking a look at the loader; it's more or less a hack to use the |
|
Yes, that's a good point. It's even unrepresentable in Wasm currently. Ok, let's close this for now. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
The file on master has the same issue -
go/misc/wasm/wasm_exec.js
Lines 104 to 108 in 006a5e7
What operating system and processor architecture are you using (
go env
)?Not relevant.
go env
OutputWhat did you do?
I'm working on https://github.com/wasm-tool/golang and ran into the issue when trying to bundle the following code:
What did you expect to see?
Wasm loading successully.
What did you see instead?
Note that the error is not really relevant, the issue is that you cannot represent the full range of a 64 integrer is JavaScript (because it uses 64 bits floats as numbers).
The text was updated successfully, but these errors were encountered: