Skip to content

AssemblyScript crashes with bus error #2740

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
SukkaW opened this issue Sep 13, 2023 · 9 comments · Fixed by #2746
Closed

AssemblyScript crashes with bus error #2740

SukkaW opened this issue Sep 13, 2023 · 9 comments · Fixed by #2746
Labels

Comments

@SukkaW
Copy link

SukkaW commented Sep 13, 2023

Bug description

image

I guess there might be an OOB error that causes Node.js to exit with a low-level bus error.

The source code of the wasm has been attached to the playground, link below.

Note that the error occurs on Node.js 18.17.1, MacBook Pro 2019. But I can't reproduce the error on the AssemblyScript playground.

Steps to reproduce

The original repo: https://github.com/SukkaW/cidr-tools-wasm

Here is the reproduction at the AssemblyScript playground.

AssemblyScript version

v0.27.9

@SukkaW SukkaW added the bug label Sep 13, 2023
@SukkaW SukkaW changed the title Unknown AssemblyScript crashes with bus error Sep 13, 2023
@CountBleck
Copy link
Member

That looks like a Node.js crash. This isn't an AS issue. This is more likely a bug in V8 or Node.js.

The "bus error" rang some bells, and using the latest version of Node might fix this, since it may include a fix for nodejs/node#46559. Or maybe it won't; I don't know how their versioning works. In that case, you may have to build Node from the master branch and try to reproduce your issue with that build to see if it still persists.

@CountBleck CountBleck closed this as not planned Won't fix, can't repro, duplicate, stale Sep 13, 2023
@CountBleck CountBleck added question and removed bug labels Sep 13, 2023
@SukkaW
Copy link
Author

SukkaW commented Sep 14, 2023

@CountBleck The bugfix of nodejs/node#46559 was included in Node.js 20.4.0, and I have updated to Node.js 20.6.1. But the crash persists:

image

@CountBleck
Copy link
Member

Now that's something I can work with.

@CountBleck CountBleck reopened this Sep 14, 2023
@CountBleck CountBleck added bug and removed question labels Sep 14, 2023
@CountBleck
Copy link
Member

CountBleck commented Sep 14, 2023

@dcodeIO I thought in-memory RTTI was completely removed? This appears to crash from trying to read nonexistent/OOB RTTI. (see rt.ts)

@CountBleck
Copy link
Member

Never mind, I am mistaken; only half of RTTI was removed.

@HerrCai0907
Copy link
Member

I also meet similar issue and then fixed bug in nodejs.

It looks like a GC related issue. Do you have some stable reproduction?

@SukkaW
Copy link
Author

SukkaW commented Sep 26, 2023

I also meet similar issue and then fixed bug in nodejs.

It looks like a GC related issue. Do you have some stable reproduction?

@HerrCai0907 I agree it is most likely a Node.js-specific issue, as I can't reproduce the issue on the AssemblyScript playground.

I've provided my relatively small code base in my original issue, it should be good enough to start with: https://github.com/SukkaW/cidr-tools-wasm

And the code on the AssemblyScript playground.

@HerrCai0907
Copy link
Member

@SukkaW A short term work around solution is removing esm option and load Webassembly module by Nodejs API or @assemblyscript/loader.

diff --git a/asconfig.json b/asconfig.json
index acd9620..a06e1e6 100644
--- a/asconfig.json
+++ b/asconfig.json
@@ -18,7 +18,5 @@
       "noAssert": true
     }
   },
-  "options": {
-    "bindings": "esm"
-  }
+  "options": {}
 }
import { readFileSync } from "fs";

let exports = (
  await WebAssembly.instantiate(readFileSync("build/debug.wasm"), {
    env: {
      abort: (a, b, c, d) => {
        console.log(a, b, c, d);
      },
    },
  })
).instance.exports;

@CountBleck
Copy link
Member

@assemblyscript/loader is practically deprecated. Don't use it if you can.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants