Skip to content

Executing unoptimized wasm file causes OOM #45480

Closed as not planned
Closed as not planned
@Nugine

Description

@Nugine

Version

v19.1.0

Platform

Linux Nugine-Ub2 5.15.0-52-generic #58-Ubuntu SMP Thu Oct 13 08:03:55 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

Dependencies:

git clone https://github.com/Nugine/simd.git -b main
cd simd
git checkout 508bffc65c3b72b889666773fe3e30a2b5a329f4
cd crates/hex-simd
just wasm-test

I uploaded artifacts here for convenience: wbg_tmp.tar.gz

tar xvf wbg_tmp.tar.gz
cd wbg_tmp
ulimit -v 4000000 # 4GB
node run.js
/home/nugine/tests/nodejs-wasm-oom/wbg-tmp/wasm-bindgen-test.js:716
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
                     ^

RangeError: WebAssembly.Instance(): Out of memory: Cannot allocate Wasm memory for new instance
    at Object.<anonymous> (/home/nugine/tests/nodejs-wasm-oom/wbg-tmp/wasm-bindgen-test.js:716:22)
    at Module._compile (node:internal/modules/cjs/loader:1205:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1259:10)
    at Module.load (node:internal/modules/cjs/loader:1068:32)
    at Module._load (node:internal/modules/cjs/loader:909:12)
    at Module.require (node:internal/modules/cjs/loader:1092:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/home/nugine/tests/nodejs-wasm-oom/wbg-tmp/run.js:3:22)
    at Module._compile (node:internal/modules/cjs/loader:1205:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1259:10)

Node.js v19.1.0

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

Always

What is the expected behavior?

It should work without OOM.

What do you see instead?

Nodejs allocates too much memory until OOM.

Additional information

See Nugine/simd@48bd619#comments

Metadata

Metadata

Assignees

No one assigned

    Labels

    v8 engineIssues and PRs related to the V8 dependency.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