Skip to content

run wasm out of memory in mac causes node crash due to SIGBUS #46559

Closed
@HerrCai0907

Description

@HerrCai0907

Version

v20.0.0-pre v16.19.0 v18.14.0

Platform

Darwin LSCN1036555 22.3.0 Darwin Kernel Version 22.3.0: Thu Jan 5 20:48:54 PST 2023; root:xnu-8792.81.2~2/RELEASE_ARM64_T6000 arm64

Subsystem

wasm

What steps will reproduce the bug?

run these code in mac, and will get SIGBUS ERROR

node tests/index.cjs 
zsh: bus error  node tests/index.cjs
const fs = require("fs");
const path = require("path");
WebAssembly.compile(fs.readFileSync(path.join(__dirname, "debug.wasm")))
  .then((module) => {
    return WebAssembly.instantiate(module);
  })
  .then((ins) => {
    ins.exports._start();
  });
(module
 (type $none_=>_none (func))
 (global $~lib/memory/__data_end i32 (i32.const 8))
 (global $~lib/memory/__stack_pointer (mut i32) (i32.const 32776))
 (global $~lib/memory/__heap_base i32 (i32.const 32776))
 (memory $0 0)
 (table $0 1 1 funcref)
 (elem $0 (i32.const 1))
 (export "_start" (func $assembly/index/_start))
 (export "memory" (memory $0))
 (func $assembly/index/_start
  memory.size $0
  i32.const 64
  i32.mul
  i32.const 1024
  i32.mul
  i32.const 3
  i32.sub
  i32.load $0
  drop
 )
)

How often does it reproduce? Is there a required condition?

100% reproduce

What is the expected behavior?

behavior should be like in other arch.

wasm://wasm/5c312dfe:1

RuntimeError: memory access out of bounds
at assembly/index/_start (wasm://wasm/5c312dfe:wasm-function[0]:0x63)
at /Users/q540239/oss/as/tests/index.cjs:9:17

What do you see instead?

NA

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    macosIssues and PRs related to the macOS platform / OSX.wasmIssues and PRs related to WebAssembly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions