The repro codes below crash by a JSException "RuntimeError: table index is out of bounds" after 2379 times of increment.
To Reproduce
Main.hs
module Main where
main :: IO ()
main = error "built with --no-main"
increment :: Int -> Int
increment n = n + 1
foreign export javascript "increment" increment :: Int -> Int
index.mjs
import * as rts from './rts.mjs';
import module from './asterius-repro.wasm.mjs';
import req from './asterius-repro.req.mjs';
async function handleModule(m) {
const asterius = await rts.newAsteriusInstance(Object.assign(req, { module: m }));
const pre = document.getElementById("counter");
let counter = 0;
const render = async () => {
pre.textContent = counter;
counter = await asterius.exports.increment(counter);
requestAnimationFrame(render);
};
requestAnimationFrame(render);
}
module.then(handleModule);
Describe the bug
The repro codes below crash by a JSException "RuntimeError: table index is out of bounds" after 2379 times of increment.
To Reproduce
Main.hs
index.mjs
Build commands (in a container)
Environment
terrorjack/asterius:lastst (4ad6bd0af93e)