-
-
Notifications
You must be signed in to change notification settings - Fork 40
Misbehaving negative integers #54
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
Seems like a problem with the |
I did some digging into this and it's because by default Lua expects to be compiled for 64-bit whereas Emscripten/WASM only support 32 bit. In luaconf.h change This will be a bit tricky because it doesn't keep a local copy of Lua. You could use the Linux patch command |
Nice found. I tried to pass |
It looks like setting that option via compiler flags was removed a little while back: lua/lua@dee6433 Barring maintaining a copy of luaconf.h, a patch (either via |
Another one-line patch option would be |
Yeah, with the limit memory test the Lua heap has enough space available to run the test with 32 bit ints, bumping the loop count up to 50 or so makes that work |
Fixed using the @clecompt-msft suggestion, I think it works for now. |
Hi! I've just started experimenting with Wasmoon for our project and I'm actually having an issue now with integers overflowing within Lua. I tracked it back to this #define LUA_32BITS 1 line in the build file. I just wanted to ask, is it possible something was overlooked here? From my readings about WASM it appears that it should support 32 and 64bit integers (and 32+64 for floats too). Is it possible switching to build a 32bit Lua has just masked a different issue where the -1 integer was treated incorrectly along the way during the "set" call? Given Lua supports 64bit integers, and so does WASM (https://webassembly.org/roadmap/) it seems a shame to exclude the possibility completely! |
FYI I have compiled this on my machine with #define LUA_32BITS 0 and all my code works fine. I don't ever call |
i also ran into the integers overflowing when trying to pass ms epochs between js and lua, easily reproducible:
|
I'm running into this error as well |
* Modify build.sh to use 64 bit floats but 32 bit ints wasm supports this but not 64 bit ints * When pushing a number see if it's within 32 bits as well as being an int if it's not then push it as a 64 bit float * Add tests for negative numbers and numbers greater than 32 bit
Negative integers do not appear to translate correctly from JS, resulting instead in a large positive integer within the Lua runtime (specifically, 2^32 minus the value, which makes it look like a signed/unsigned issue). This can be observed via the following code:
The same result occurs with function return values, etc.
The text was updated successfully, but these errors were encountered: