Skip to content

Commit

Permalink
updpatch: nodejs 22.9.0-1
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kxxt committed Oct 4, 2024
1 parent f5dacfc commit 73d5edd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions nodejs/riscv64.patch
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
--- PKGBUILD
+++ PKGBUILD
@@ -40,6 +40,11 @@ validpgpkeys=(
'890C08DB8579162FEE0DF9DB8BEAB4DFCF555EF4' # RafaelGSS <rafael.nunu@hotmail.com>
@@ -41,6 +41,12 @@ validpgpkeys=(
'C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C' # Richard Lau <rlau@redhat.com>
)

+prepare() {
+ cd node
+ patch -Np1 -i ../fix-trap-handler.patch
+ patch -Np1 -i ../v8-disable-trap-handler.patch
+}
+
build() {
cd node

@@ -76,4 +81,7 @@ package() {
@@ -77,4 +83,8 @@ package() {
install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/nodejs/
}

+source+=("fix-trap-handler.patch")
+sha512sums+=('f2ff6da8cf5dcc994a7a20342e2928dc1821fbbf42891009a6234b6051277e0200d7e3fbba63b9a2773887591d0ad5ceb1bb3d25e5efeb557f6d00109a80253c')
+
+source+=("fix-trap-handler.patch"
+ "v8-disable-trap-handler.patch")
+sha512sums+=('f2ff6da8cf5dcc994a7a20342e2928dc1821fbbf42891009a6234b6051277e0200d7e3fbba63b9a2773887591d0ad5ceb1bb3d25e5efeb557f6d00109a80253c'
+ 'b6495aefd36915969ee848cca350a565317c74864cd33e6a69a310ed9cbc71dfbd91f31e8c6176667f6f72daa1762eb4d519700a024cdbe8b18049100a9e3c80')
# vim:set ts=2 sw=2 et:

0 comments on commit 73d5edd

Please sign in to comment.