Skip to content

Alignment fault happens when closing lua vm #128

Description

@myzhan

First of all, I can't reproduce this issue in the master branch of wasmoon.

What I did:

  1. I compile lua and c files in my project, with emscripten's SAFE_HEAP option set to 1.
  2. I compile wasmoon with the glue.js.
  3. I run wasmoon with glus.wasm.

Testcase:

const { LuaFactory } = require('./index');

(async () => {
  // Initialize a new lua environment factory
  const factory = new LuaFactory();
  // Create a standalone lua environment from the factory
  const lua = await factory.createEngine();

  lua.global.close();
})();

Error:

Aborted(alignment fault)
/Users/zhanqp/src/sconn_client/test/nodejs/index.js:1829
      /** @suppress {checkTypes} */ var e = new WebAssembly.RuntimeError(what);
                                            ^

RuntimeError: Aborted(alignment fault)
    at abort (/Users/zhanqp/src/sconn_client/test/nodejs/index.js:1829:45)
    at alignfault (/Users/zhanqp/src/sconn_client/test/nodejs/index.js:1600:7)
    at sconn_client.wasm (wasm://wasm/sconn_client.wasm-002ca6f6:wasm-function[1360]:0xa5ffa)
    at sconn_client.wasm.gettable (wasm://wasm/sconn_client.wasm-002ca6f6:wasm-function[789]:0x6e6f7)
    at sconn_client.wasm.lua_rawgeti (wasm://wasm/sconn_client.wasm-002ca6f6:wasm-function[791]:0x6e910)
    at sconn_client.wasm.luaL_unref (wasm://wasm/sconn_client.wasm-002ca6f6:wasm-function[72]:0x52ac)
    at /Users/zhanqp/src/sconn_client/test/nodejs/index.js:1861:16
    at Object.ccall (/Users/zhanqp/src/sconn_client/test/nodejs/index.js:5772:17)
    at LuaWasm.pointersToBeFreed [as luaL_unref] (/Users/zhanqp/src/sconn_client/test/nodejs/index.js:6777:49)
    at FunctionTypeExtension.close (/Users/zhanqp/src/sconn_client/test/nodejs/index.js:715:38)

Node.js v20.18.0

This issue happens when FunctionTypeExtension.close trying to close a lua thread.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions