-
Notifications
You must be signed in to change notification settings - Fork 3
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
[Regression] v8 wasm error when running yarn install with yarn v3+ #3
Comments
Other errors occurred in another run:
|
nodejs 1d29d81c69a5e03d99a3d3e597bc0eeed433e47d v8 12.3.219.16 is good |
The failing [pid 2271951] mmap(NULL, 10737479680, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = -1 ENOMEM (Cannot allocate memory)
[pid 2271951] mmap(NULL, 10737479680, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = -1 ENOMEM (Cannot allocate memory)
[pid 2272002] mmap(0x13301c0000, 520192, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x13301c0000
[pid 2271949] mmap(NULL, 10737479680, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = -1 ENOMEM (Cannot allocate memory)
[pid 2271999] mmap(0x329a300000, 520192, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0 <unfinished ...>
[pid 2271949] mmap(NULL, 10737479680, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0 <unfinished ...> |
Backtrace on nodejs 22.9.0 debug build with line info: [pid 2400505] mmap(NULL, 10737479680, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = -1 ENOMEM (Cannot allocate memory)
> /usr/lib/libc.so.6(__GI___mmap64+0x18) [0xc8ca0]
> out/Debug/node() [0x71ef748] v8::base::(anonymous namespace)::Allocate(void*, unsigned long, v8::base::OS::MemoryPermission, v8::base::(anonymous namespace)::PageType) at /home/kxxt/node/out/Debug/../../deps/v8/src/base/platform/platform-posix.cc:158
> out/Debug/node() [0x71efb6a] v8::base::OS::Allocate(void*, unsigned long, unsigned long, v8::base::OS::MemoryPermission) at /home/kxxt/node/out/Debug/../../deps/v8/src/base/platform/platform-posix.cc:415
> out/Debug/node() [0x71def14] v8::base::PageAllocator::AllocatePages(void*, unsigned long, unsigned long, v8::PageAllocator::Permission) at /home/kxxt/node/out/Debug/../../deps/v8/src/base/page-allocator.cc:55
> out/Debug/node() [0x6484064] v8::internal::AllocatePages(v8::PageAllocator*, void*, unsigned long, unsigned long, v8::PageAllocator::Permission) at /home/kxxt/node/out/Debug/../../deps/v8/src/utils/allocation.cc:174
> out/Debug/node() [0x5cc4dae] v8::internal::BackingStore::TryAllocateAndPartiallyCommitMemory(v8::internal::Isolate*, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, v8::internal::WasmMemoryFlag, v8::internal::SharedFlag)::{lambda()#1}::operator()() const at /home/kxxt/node/out/Debug/../../deps/v8/src/objects/backing-store.cc:360
> out/Debug/node() [0x5cca5b0] bool std::__invoke_impl<bool, v8::internal::BackingStore::TryAllocateAndPartiallyCommitMemory(v8::internal::Isolate*, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, v8::internal::WasmMemoryFlag, v8::internal::SharedFlag)::{lambda()#1}&>(std::__invoke_other, v8::internal::BackingStore::TryAllocateAndPartiallyCommitMemory(v8::internal::Isolate*, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, v8::internal::WasmMemoryFlag, v8::internal::SharedFlag)::{lambda()#1}&) at /usr/include/c++/14.2.1/bits/invoke.h:61 (discriminator 1)
> out/Debug/node() [0x5cc9822] std::enable_if<is_invocable_r_v<bool, v8::internal::BackingStore::TryAllocateAndPartiallyCommitMemory(v8::internal::Isolate*, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, v8::internal::WasmMemoryFlag, v8::internal::SharedFlag)::{lambda()#1}&>, bool>::type std::__invoke_r<bool, v8::internal::BackingStore::TryAllocateAndPartiallyCommitMemory(v8::internal::Isolate*, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, v8::internal::WasmMemoryFlag, v8::internal::SharedFlag)::{lambda()#1}&>(v8::internal::BackingStore::TryAllocateAndPartiallyCommitMemory(v8::internal::Isolate*, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, v8::internal::WasmMemoryFlag, v8::internal::SharedFlag)::{lambda()#1}&) at /usr/include/c++/14.2.1/bits/invoke.h:114 (discriminator 1)
> out/Debug/node() [0x5cc83e8] std::_Function_handler<bool (), v8::internal::BackingStore::TryAllocateAndPartiallyCommitMemory(v8::internal::Isolate*, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, v8::internal::WasmMemoryFlag, v8::internal::SharedFlag)::{lambda()#1}>::_M_invoke(std::_Any_data const&) at /usr/include/c++/14.2.1/bits/std_function.h:290 (discriminator 1)
> out/Debug/node(std::function<bool ()>::operator()() const+0x34) [0x5cc785a] std::function<bool ()>::operator()() const at /usr/include/c++/14.2.1/bits/std_function.h:591
> out/Debug/node() [0x5cc4d12] v8::internal::BackingStore::TryAllocateAndPartiallyCommitMemory(v8::internal::Isolate*, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, v8::internal::WasmMemoryFlag, v8::internal::SharedFlag)::{lambda(std::function<bool ()> const&)#1}::operator()(std::function<bool ()> const&) const at /home/kxxt/node/out/Debug/../../deps/v8/src/objects/backing-store.cc:338
> out/Debug/node() [0x5cc4fca] v8::internal::BackingStore::TryAllocateAndPartiallyCommitMemory(v8::internal::Isolate*, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, v8::internal::WasmMemoryFlag, v8::internal::SharedFlag) at /home/kxxt/node/out/Debug/../../deps/v8/src/objects/backing-store.cc:364 (discriminator 1)
> out/Debug/node() [0x5cc538a] v8::internal::BackingStore::AllocateWasmMemory(v8::internal::Isolate*, unsigned long, unsigned long, v8::internal::WasmMemoryFlag, v8::internal::SharedFlag)::{lambda(unsigned long)#1}::operator()(unsigned long) const at /home/kxxt/node/out/Debug/../../deps/v8/src/objects/backing-store.cc:450
> out/Debug/node() [0x5cc559e] v8::internal::BackingStore::AllocateWasmMemory(v8::internal::Isolate*, unsigned long, unsigned long, v8::internal::WasmMemoryFlag, v8::internal::SharedFlag) at /home/kxxt/node/out/Debug/../../deps/v8/src/objects/backing-store.cc:457
> out/Debug/node() [0x6b8d09c] v8::internal::WasmMemoryObject::New(v8::internal::Isolate*, int, int, v8::internal::SharedFlag, v8::internal::WasmMemoryFlag) at /home/kxxt/node/out/Debug/../../deps/v8/src/wasm/wasm-objects.cc:734
> out/Debug/node() [0x69b05fa] v8::internal::wasm::InstanceBuilder::AllocateMemory(unsigned int) at /home/kxxt/node/out/Debug/../../deps/v8/src/wasm/module-instantiate.cc:2478
> out/Debug/node() [0x69a8f4a] v8::internal::wasm::InstanceBuilder::Build() at /home/kxxt/node/out/Debug/../../deps/v8/src/wasm/module-instantiate.cc:1140
> out/Debug/node() [0x69a7f6a] v8::internal::wasm::InstantiateToInstanceObject(v8::internal::Isolate*, v8::internal::wasm::ErrorThrower*, v8::internal::Handle<v8::internal::WasmModuleObject>, v8::internal::MaybeHandle<v8::internal::JSReceiver>, v8::internal::MaybeHandle<v8::internal::JSArrayBuffer>) at /home/kxxt/node/out/Debug/../../deps/v8/src/wasm/module-instantiate.cc:1007
> out/Debug/node() [0x6b1f728] v8::internal::wasm::WasmEngine::SyncInstantiate(v8::internal::Isolate*, v8::internal::wasm::ErrorThrower*, v8::internal::Handle<v8::internal::WasmModuleObject>, v8::internal::MaybeHandle<v8::internal::JSReceiver>, v8::internal::MaybeHandle<v8::internal::JSArrayBuffer>) at /home/kxxt/node/out/Debug/../../deps/v8/src/wasm/wasm-engine.cc:671
> out/Debug/node() [0x6b570a0] v8::(anonymous namespace)::WebAssemblyInstanceImpl(v8::FunctionCallbackInfo<v8::Value> const&) at /home/kxxt/node/out/Debug/../../deps/v8/src/wasm/wasm-js.cc:966 (discriminator 3)
> out/Debug/node() [0x6b614e0] v8::internal::wasm::WebAssemblyInstance(v8::FunctionCallbackInfo<v8::Value> const&) at /home/kxxt/node/out/Debug/../../deps/v8/src/wasm/wasm-js.cc:2963
> out/Debug/node() [0x53ed9d4] v8::internal::FunctionCallbackArguments::Call(v8::internal::Tagged<v8::internal::FunctionTemplateInfo>) at /home/kxxt/node/out/Debug/../../deps/v8/src/api/api-arguments-inl.h:115
> out/Debug/node() [0x53ef982] v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<true>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, unsigned long*, int) at /home/kxxt/node/out/Debug/../../deps/v8/src/builtins/builtins-api.cc:110 (discriminator 1)
> out/Debug/node() [0x53ee0d4] v8::internal::Builtin_Impl_HandleApiConstruct(v8::internal::BuiltinArguments, v8::internal::Isolate*) at /home/kxxt/node/out/Debug/../../deps/v8/src/builtins/builtins-api.cc:141 (discriminator 1)
> out/Debug/node() [0x53edeea] v8::internal::Builtin_HandleApiConstruct(int, unsigned long*, v8::internal::Isolate*) at /home/kxxt/node/out/Debug/../../deps/v8/src/builtins/builtins-api.cc:132 (discriminator 1)
> out/Debug/node() [0x6e39dac] Builtins_CEntry_Return1_ArgvOnStack_BuiltinExit at /home/kxxt/node/out/Debug/../../deps/v8/src/builtins/torque-internal.tq:113
> out/Debug/node() [0x6e39dac] Builtins_CEntry_Return1_ArgvOnStack_BuiltinExit at /home/kxxt/node/out/Debug/../../deps/v8/src/builtins/torque-internal.tq:113 |
There are actually two bugs in this issue. FirstThis bug is related to the enable of OOB trap handler(nodejs/node#52888). The trap handler tries to allocate a guard vma of 10 GiB size(https://github.com/nodejs/node/blob/09a8440b45f69651ff52110cb1bc2dde9e14e2e8/deps/v8/src/objects/backing-store.cc#L38), which is highly likely to fail on sv39 systems. maps when Failure happens: /proc/{PID_of_nodejs_yarn}/maps
There's no remaining area to satisify this 10GiB request. SecondThe above issue is not a problem on sv48 systems since sv48 systems enjoy 128 TB userspace virtual memory. But the following error still happens:
|
Disable v8's trap handler[1] to workaround ENOMEM on sv39 systems[2]. v8's OOB trap handler for wasm tries to allocate a 10 GB guard region[3], but unfortunately on sv39 systems we only have 256GB virtual memory for userspace, which is usually already exhausted by the node process and leads to `WebAssembly.Instance(): Out of memory: Cannot allocate Wasm memory for new instance` errors There is a second bug in [2], which needs to be investigated separately and disabling trap handler won't fix it. [1]: https://chromium-review.googlesource.com/c/v8/v8/+/5227604 [2]: riscv-forks/electron#3 (comment) [3]: https://github.com/nodejs/node/blob/09a8440b45f69651ff52110cb1bc2dde9e14e2e8/deps/v8/src/objects/backing-store.cc#L38
Disable v8's trap handler[1] to workaround ENOMEM on sv39 systems[2]. v8's OOB trap handler for wasm tries to allocate a 10 GB guard region[3], but unfortunately on sv39 systems we only have 256GB virtual memory for userspace, which is usually already exhausted by the node process and leads to `WebAssembly.Instance(): Out of memory: Cannot allocate Wasm memory for new instance` errors There is a second bug in [2], which needs to be investigated separately and disabling trap handler won't fix it. [1]: https://chromium-review.googlesource.com/c/v8/v8/+/5227604 [2]: riscv-forks/electron#3 (comment) [3]: https://github.com/nodejs/node/blob/09a8440b45f69651ff52110cb1bc2dde9e14e2e8/deps/v8/src/objects/backing-store.cc#L38
The first bug can be workaround-ed by disabling the trap handler with the following patch: diff --git a/deps/v8/src/trap-handler/trap-handler.h b/deps/v8/src/trap-handler/trap-handler.h
index 4bf95b8c22..2612c00a07 100644
--- a/deps/v8/src/trap-handler/trap-handler.h
+++ b/deps/v8/src/trap-handler/trap-handler.h
@@ -46,7 +46,7 @@ namespace trap_handler {
#define V8_TRAP_HANDLER_SUPPORTED true
// RISCV64 (non-simulator) on Linux.
#elif V8_TARGET_ARCH_RISCV64 && V8_HOST_ARCH_RISCV64 && V8_OS_LINUX
-#define V8_TRAP_HANDLER_SUPPORTED true
+#define V8_TRAP_HANDLER_SUPPORTED false
// RISCV64 simulator on x64 on Linux
#elif V8_TARGET_ARCH_RISCV64 && V8_HOST_ARCH_X64 && V8_OS_LINUX
#define V8_TRAP_HANDLER_VIA_SIMULATOR But the second bug still occurs after disabling the trap handler. |
Disable v8's trap handler[1] to workaround ENOMEM on sv39 systems[2]. v8's OOB trap handler for wasm tries to allocate a 10 GB guard region[3], but unfortunately on sv39 systems we only have 256GB virtual memory for userspace, which is usually already exhausted by the node process and leads to `WebAssembly.Instance(): Out of memory: Cannot allocate Wasm memory for new instance` errors There is a second bug in [2], which needs to be investigated separately and disabling trap handler won't fix it. [1]: https://chromium-review.googlesource.com/c/v8/v8/+/5227604 [2]: riscv-forks/electron#3 (comment) [3]: https://github.com/nodejs/node/blob/09a8440b45f69651ff52110cb1bc2dde9e14e2e8/deps/v8/src/objects/backing-store.cc#L38
V8 Bug report: https://issues.chromium.org/issues/360030990 (Unfortunately not visible to public)
Running
yarn install
with https://github.com/hedgedoc/hedgedoc produces lots of unexpected errors:Test results on different version:
(To test with electron, rename
electron
tonode
and setELECTRON_RUN_AS_NODE
)Current bisection range: 12.2.281.27..12.4.254.20 (968 commits in total)
The text was updated successfully, but these errors were encountered: