nodejs-14.2.0, which is keyworded for ppc64, crashes with a SIGSEGV on startup on ppc64. If the "snapshot" use flag is enabled (which is the default), it does not even install because it segfaults when trying to create the snapshot. The problem seems to be that it is confused about what ABI it should be using. ---8<-- hakua:~% gdb /usr/bin/node GNU gdb (Gentoo 9.1 vanilla) 9.1 Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "powerpc64-unknown-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <https://bugs.gentoo.org/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from /usr/bin/node... (No debugging symbols found in /usr/bin/node) (gdb) run Starting program: /usr/bin/node [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". [New Thread 0x7ffff510f140 (LWP 17827)] [New Thread 0x7ffff48ff140 (LWP 17828)] [New Thread 0x7fffeffff140 (LWP 17829)] [New Thread 0x7fffef7ef140 (LWP 17830)] [New Thread 0x7fffeefdf140 (LWP 17831)] Thread 1 "node" received signal SIGSEGV, Segmentation fault. 0x7c0802a6f8010010 in ?? () (gdb) disass 0x7c0802a6f8010010,0x7c0802a6f8010020 Dump of assembler code from 0x7c0802a6f8010010 to 0x7c0802a6f8010020: => 0x7c0802a6f8010010: Cannot access memory at address 0x7c0802a6f8010010 (gdb) up #1 0x0000000100c1a4d8 in ?? () (gdb) disass 0x0000000100c1a4b4,0x0000000100c1a4e0 Dump of assembler code from 0x100c1a4b4 to 0x100c1a4e0: 0x0000000100c1a4b4: ld r9,0(r22) 0x0000000100c1a4b8: lwa r7,16(r28) 0x0000000100c1a4bc: ld r11,16(r22) 0x0000000100c1a4c0: mr r5,r20 0x0000000100c1a4c4: mr r4,r21 0x0000000100c1a4c8: addi r3,r29,128 0x0000000100c1a4cc: mtctr r9 0x0000000100c1a4d0: ld r2,8(r22) 0x0000000100c1a4d4: bctrl => 0x0000000100c1a4d8: ld r2,40(r1) 0x0000000100c1a4dc: ld r9,304(r31) End of assembler dump. (gdb) info reg ctr ctr 0x7c0802a6f8010010 8937396376665391120 (gdb) info reg r22 r22 0x101464820 4316350496 (gdb) disass 0x101464820 No function contains specified address. (gdb) disass 0x101464820,0x101464840 Dump of assembler code from 0x101464820 to 0x101464840: 0x0000000101464820: mflr r0 0x0000000101464824: std r0,16(r1) 0x0000000101464828: addi r1,r1,-144 0x000000010146482c: std r31,136(r1) 0x0000000101464830: std r30,128(r1) 0x0000000101464834: std r29,120(r1) 0x0000000101464838: std r28,112(r1) 0x000000010146483c: std r27,104(r1) End of assembler dump. (gdb) ---8<--- As can be seen, r22 is expected to contain a function descriptor (ABIv1 function pointer); the jump address is fetched from 0(r22) and the new TOC from 8(r22). However, r22 is actually containing a pointer to code (an ABIv2 function pointer). Reproducible: Always Steps to Reproduce: 1.Emerge net-libs/nodejs-14.2.0 with USE=-snapshot (so that it builds at all) on ppc64 ABIv1 (big endian) 2.Run "nodejs" 3. Actual Results: It crashes with a SIGSEGV Expected Results: It does not crash
Created attachment 644546 [details] emerge --info output
Upstreams issue: https://github.com/nodejs/node/issues/29534
Created attachment 644568 [details, diff] Patch to fix crash on ELFv1 With this patch node starts without crashing. A build with USE=+snapshot seems to work as well.
The fix is in V8 8.6 and 8.5.184++. It seems node.js hasn't pulled the fix yet...
(In reply to Marcus Comstedt from comment #4) > The fix is in V8 8.6 and 8.5.184++. It seems node.js hasn't pulled the fix > yet... They're a bit slow sometimes. E.g.: bug #731654 describes a security issue in the bundled npm that has not been fixed in the master tree[0] yet. [0] https://github.com/nodejs/node/commits/master/deps/npm
Comment on attachment 644568 [details, diff] Patch to fix crash on ELFv1 Fails on 14.5.0: * Applying nodejs-14.5.0-ABI_USES_FUNCTION_DESCRIPTORS.patch ... patching file deps/v8/src/compiler/backend/instruction-selector.cc patching file deps/v8/src/compiler/backend/ppc/code-generator-ppc.cc Hunk #1 FAILED at 1033. 1 out of 1 hunk FAILED -- saving rejects to file deps/v8/src/compiler/backend/ppc/code-generator-ppc.cc.rej [...]
The context around #if defined(_AIX) in code-generator-ppc.c changed. You need to edit the context line int offset = 9 * kInstrSize; so that it says int offset = 20 * kInstrSize; instead. Then the patch applies again.
I can confirm Marcus patch works well for nodejs-14.4.0 on ppc64 and also nodejs-14.5.0 builds well with his modifications suggested.
(In reply to ernsteiswuerfel from comment #8) > I can confirm Marcus patch works well for nodejs-14.4.0 on ppc64 and also > nodejs-14.5.0 builds well with his modifications suggested. Given the change seems to have been upstreamed and is preventing stabilisation, can we apply this?
FYI: It looks like the fix will be included in nodejs-15. https://github.com/nodejs/node/pull/33866#event-3888151132
(In reply to Marcus Comstedt from comment #10) > FYI: > It looks like the fix will be included in nodejs-15. > https://github.com/nodejs/node/pull/33866#event-3888151132 Maybe we can backport this?
Backporting newer v8 to nodejs-14 would almost certainly be more trouble than it's worth but since they merged Marcus's patch almost verbatim, I'll just add this to nodejs-14.15.0+.
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1398b77a96625ee50dd430fb4d265b7f793322be commit 1398b77a96625ee50dd430fb4d265b7f793322be Author: Marek Szuba <marecki@gentoo.org> AuthorDate: 2020-11-09 13:52:36 +0000 Commit: Marek Szuba <marecki@gentoo.org> CommitDate: 2020-11-09 15:05:39 +0000 net-libs/nodejs: bump to 14.15.0 Includes subslotting, support for building against bundled ICU, a fix for PPC64 crashes and python3_9 support. Closes: https://bugs.gentoo.org/724978 Closes: https://bugs.gentoo.org/728110 Closes: https://bugs.gentoo.org/747100 Closes: https://bugs.gentoo.org/749852 Closes: https://github.com/gentoo/gentoo/pull/17809 Signed-off-by: Marek Szuba <marecki@gentoo.org> net-libs/nodejs/Manifest | 2 +- .../files/nodejs-14.15.0-fix_ppc64_crashes.patch | 33 +++++++++++ net-libs/nodejs/metadata.xml | 1 + ...nodejs-14.14.0.ebuild => nodejs-14.15.0.ebuild} | 64 ++++++++++------------ 4 files changed, 65 insertions(+), 35 deletions(-)