Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Crash by "table index is out of bounds" #861

Open
y-taka-23 opened this issue Jul 31, 2021 · 0 comments
Open

Crash by "table index is out of bounds" #861

y-taka-23 opened this issue Jul 31, 2021 · 0 comments

Comments

@y-taka-23
Copy link

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

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);

Build commands (in a container)

# ahc-cabal install --installdir . --install-method copy --overwrite-policy always
# ahc-dist input-exe asterius-repro --input-mjs index.mjs --no-main --browser --bundle

Environment

  • Asterius Image: terrorjack/asterius:lastst (4ad6bd0af93e)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant