Skip to content

riscv64: every script segfaults in Runtime_InstallBaselineCode since v24.22.0 (backport of V8 0b94a9fd23ba dropped the runtime argument) #67655

Open

Description

@wbar

Version

v24.22.1, built from source. v24.22.3 and the head of v24.x carry the same line. v24.21.0 and main are not affected.

Platform

Linux 6.18 riscv64 (SpacemiT K3), Ubuntu 26.04, gcc 15.2, `./configure --openssl-no-asm`

Subsystem

deps (V8, riscv64 port)

What steps will reproduce the bug?

Build v24.22.1 natively on riscv64 and run any script:

$ out/Release/node --version
v24.22.1
$ out/Release/node -p 1+1
Segmentation fault (core dumped)

--no-sparkplug and --jitless both avoid it.

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

Always, on the first function that takes the baseline path.

What is the expected behavior? Why is that the expected behavior?

2

What do you see instead?

Thread 1 "MainThread" received signal SIGSEGV, Segmentation fault.
#0  v8::internal::Runtime_InstallBaselineCode(int, unsigned long*, v8::internal::Isolate*) ()
#1  Builtins_CEntry_Return1_ArgvOnStack_NoBuiltinExit ()

Additional information

#65753 (backport of V8 0b94a9fd23ba, in v24.22.0) rewrote MacroAssembler::GenerateTailCallToReturnedCode in deps/v8/src/codegen/riscv/macro-assembler-riscv.cc. The Push went from four registers to three and lost the second kJavaScriptCallTargetRegister, which is the one argument of the CallRuntime(function_id, 1) that follows. The runtime function then reads the slot below as its argument: in the crash args[0] is 0x100000000, the Smi-tagged argument count, not a JSFunction. The disassembly of Builtins_InterpreterEntryTrampoline shows three stores before the call; the v24.21.0 source pushes four.

main pushes the function separately before the call, so only the backport is affected. Restoring the register fixes it:

--- a/deps/v8/src/codegen/riscv/macro-assembler-riscv.cc
+++ b/deps/v8/src/codegen/riscv/macro-assembler-riscv.cc
@@ -202,7 +202,7 @@
     Push(kJavaScriptCallDispatchHandleRegister);
 #endif
     Push(kJavaScriptCallTargetRegister, kJavaScriptCallNewTargetRegister,
-         kJavaScriptCallArgCountRegister);
+         kJavaScriptCallArgCountRegister, kJavaScriptCallTargetRegister);
 
     CallRuntime(function_id, 1);
     // Use the return value before restoring a0

With that line a native build runs JavaScript, workers, child processes and npm. I have not checked whether the unofficial riscv64 binaries of 24.22.x show the same crash.

Activity

  1. added
    riscv64
    on Nov 20, 2026
  2. sxa commented on Nov 20, 2026

    @sxa
    Member

    I have not checked whether the unofficial riscv64 binaries of 24.22.x show the same crash.

    Ref: nodejs/unofficial-builds#253

  3. HougeLangley commented on Nov 24, 2026

    @HougeLangley

    Independent confirmation on SpacemiT K3 (X100), Ubuntu 26.04.1, gcc 15.2.0, glibc 2.43 — plus test results for the fix in #67430 (landed as b3c5918 on v24.x-staging).

    Affected binaries

    • node-v24.22.3-linux-riscv64.tar.xz from unofficial-builds (sha256 9c8c8df394272c2ad69becb08c1e2028b271cd35b450ed98ca3c67c1fa1c68d0): node --version works, but node -e "" and node -p 1 segfault every time (exit 139). --no-lazy, --no-use-osr and --single-threaded do not help; only --no-sparkplug (and --jitless) avoid it.
    • Native build of the v24.22.3 source tarball (default ./configure, only --prefix set): identical crash. gdb: SIGSEGV at Runtime_InstallBaselineCode+52 (ld a2,0(a4), a4 = 0x30000001f) with argv[0] = 0x300000000 = Smi(3) = the JS argument count — the runtime function receives the argc slot as its function argument, exactly as analysed above.

    With the one-line fix

    Cherry-pick of ec2f506f97df, i.e. Push(kJavaScriptCallTargetRegister); before CallRuntime(function_id, 1), applied to the same native build:

    • startup, hot loops, WebAssembly, async/timers, --always-sparkplug and --maglev stress: all pass;
    • tools/test.py on a 495-file subset of test/parallel (vm, timer, promise, fs-read, wasm, worker, http-client, http-server): 496 passed, 0 failed;
    • a large tsx-based service has been running on it since without issues.

    Not affected

    Node v26.9.0 riscv64 (V8 14.6.202.34-node.32) runs the same scripts fine on the same board.

    So the cherry-pick is confirmed sufficient on K3 hardware as well — looking forward to v24.23.0.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    riscv64

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions