Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

"Allocation failed - process out of memory" on Apple Silicon (aka M1) #71

Closed
tsabolov opened this issue Mar 23, 2021 · 2 comments · Fixed by #95
Closed

"Allocation failed - process out of memory" on Apple Silicon (aka M1) #71

tsabolov opened this issue Mar 23, 2021 · 2 comments · Fixed by #95

Comments

@tsabolov
Copy link

I am running the library on an Apple Silicon (aka M1) MacBookPro and receive the subject error.

Steps to reproduce (a series of commands in shell):

$ node -p "process.arch + ' ' + process.platform + ' ' + process.version"
arm64 darwin v14.16.0

$ mkdir bbs-expt
$ cd $_
$ npm init -y
Wrote to /Users/[REDACTED]/dev/expt/bbs-expt/package.json:

{
  "name": "bbs-expt",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}
$ npm i @mattrglobal/bbs-signatures

[NPM OUTPUT GOES HERE]

$ echo "require('@mattrglobal/bbs-signatures')" > index.js
$ node index.js

This results in node process crash with the following output:

(node:32546) Warning: Accessing non-existent property 'abort' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)

<--- Last few GCs --->

[32546:0x150008000]      125 ms: Scavenge 10.0 (11.7) -> 9.7 (12.4) MB, 0.4 / 0.0 ms  (average mu = 1.000, current mu = 1.000) allocation failure


<--- JS stacktrace --->

FATAL ERROR: wasm code commit Allocation failed - process out of memory
 1: 0x1044310cc node::Abort() [/opt/homebrew/opt/node@14/bin/node]
 2: 0x10443124c std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string<std::nullptr_t>(char const*) [/opt/homebrew/opt/node@14/bin/node]
 3: 0x104531448 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/opt/homebrew/opt/node@14/bin/node]
 4: 0x1045313dc v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/opt/homebrew/opt/node@14/bin/node]
 5: 0x1049a42e4 v8::internal::wasm::WasmCodeAllocator::AllocateForCodeInRegion(v8::internal::wasm::NativeModule*, unsigned long, v8::base::AddressRegion, v8::internal::wasm::WasmCodeAllocator::OptionalLock const&) [/opt/homebrew/opt/node@14/bin/node]
 6: 0x1049a4de8 v8::internal::wasm::NativeModule::CreateEmptyJumpTableInRegion(int, v8::base::AddressRegion, v8::internal::wasm::WasmCodeAllocator::OptionalLock const&) [/opt/homebrew/opt/node@14/bin/node]
 7: 0x1049a3d3c v8::internal::wasm::NativeModule::AddCodeSpace(v8::base::AddressRegion, v8::internal::wasm::WasmCodeAllocator::OptionalLock const&) [/opt/homebrew/opt/node@14/bin/node]
 8: 0x1049a4c04 v8::internal::wasm::NativeModule::NativeModule(v8::internal::wasm::WasmEngine*, v8::internal::wasm::WasmFeatures const&, v8::internal::VirtualMemory, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>, std::__1::shared_ptr<v8::internal::Counters>, std::__1::shared_ptr<v8::internal::wasm::NativeModule>*) [/opt/homebrew/opt/node@14/bin/node]
 9: 0x1049a6c18 v8::internal::wasm::WasmCodeManager::NewNativeModule(v8::internal::wasm::WasmEngine*, v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, unsigned long, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>) [/opt/homebrew/opt/node@14/bin/node]
10: 0x1049b1af4 v8::internal::wasm::WasmEngine::NewNativeModule(v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>, unsigned long) [/opt/homebrew/opt/node@14/bin/node]
11: 0x104987df0 v8::internal::wasm::AsyncCompileJob::CreateNativeModule(std::__1::shared_ptr<v8::internal::wasm::WasmModule const>, unsigned long) [/opt/homebrew/opt/node@14/bin/node]
12: 0x104987fa4 v8::internal::wasm::AsyncCompileJob::GetOrCreateNativeModule(std::__1::shared_ptr<v8::internal::wasm::WasmModule const>, unsigned long) [/opt/homebrew/opt/node@14/bin/node]
13: 0x10498ee3c v8::internal::wasm::AsyncCompileJob::PrepareAndStartCompile::RunInForeground(v8::internal::wasm::AsyncCompileJob*) [/opt/homebrew/opt/node@14/bin/node]
14: 0x10498ec68 v8::internal::wasm::AsyncCompileJob::CompileStep::Run(v8::internal::wasm::AsyncCompileJob*, bool) [/opt/homebrew/opt/node@14/bin/node]
15: 0x10498eb78 v8::internal::wasm::AsyncCompileJob::CompileTask::RunInternal() [/opt/homebrew/opt/node@14/bin/node]
16: 0x104484bb0 node::PerIsolatePlatformData::RunForegroundTask(std::__1::unique_ptr<v8::Task, std::__1::default_delete<v8::Task> >) [/opt/homebrew/opt/node@14/bin/node]
17: 0x104483ca4 node::PerIsolatePlatformData::FlushForegroundTasksInternal() [/opt/homebrew/opt/node@14/bin/node]
18: 0x104484d6c node::NodePlatform::DrainTasks(v8::Isolate*) [/opt/homebrew/opt/node@14/bin/node]
19: 0x104464cfc node::NodeMainInstance::Run() [/opt/homebrew/opt/node@14/bin/node]
20: 0x10440c800 node::Start(int, char**) [/opt/homebrew/opt/node@14/bin/node]
21: 0x195b1df34 start [/usr/lib/system/libdyld.dylib]
[1]    32546 abort      node index.js

However, doing the same with the latest Node.js (v15.12.0) works well (assuming the files from above are still in place):

$ node -p "process.arch + ' ' + process.platform + ' ' + process.version"
arm64 darwin v15.12.0

$ node index.js
(node:32587) Warning: Accessing non-existent property 'abort' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)

$ node --trace-warnings index.js
(node:32591) Warning: Accessing non-existent property 'abort' of module exports inside circular dependency
    at emitCircularRequireWarning (node:internal/modules/cjs/loader:698:11)
    at Object.get (node:internal/modules/cjs/loader:712:5)
    at asmFunc (/Users/[REDACTED]/dev/expt/bbs-expt/node_modules/@mattrglobal/bbs-signatures/lib/wasm_asm.js:95:18)
    at Object.<anonymous> (/Users/[REDACTED]/dev/expt/bbs-expt/node_modules/@mattrglobal/bbs-signatures/lib/wasm_asm.js:184429:18)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:996:19)
    at require (node:internal/modules/cjs/helpers:92:18)

Any ideas, if this could be fixed for Node v14?
Also what about the non-existing property issue?

@tsabolov tsabolov changed the title Allocation failed - process out of memory on Apple Silicon (aka M1) "Allocation failed - process out of memory" on Apple Silicon (aka M1) Mar 23, 2021
@tplooker
Copy link
Member

tplooker commented May 23, 2021

@tsabolov I have recently made some changes to how we generate the WASM module. Are you able to try out the latest unstable release 0.5.1-unstable.c016ef
? I'd like to address this issue before the next stable release.

@tsabolov
Copy link
Author

@tplooker I have done a simple test using the build, and it works. We still need to check on the real scenarios, but I guess the problem is solved now. Thank you for your job!

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

Successfully merging a pull request may close this issue.

2 participants