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

Đang mở Phù hợp với người mới
#67,655 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c, cpp, javascript
Lĩnh vực
backend, operating-systems

Hướng nghiên cứu

Bắt đầu với bản backport V8 trong #65753 và kiểm tra deps/v8/src/codegen/riscv/macro-assembler-riscv.cc, đặc biệt là MacroAssembler::GenerateTailCallToReturnedCode. So sánh các thao tác đẩy thanh ghi của nó với v24.21.0 và main, sau đó biên dịch và chạy out/Release/node -p 1+1 trên riscv64. Công việc hoàn tất khi lệnh in ra 2 mà không bị lỗi phân đoạn.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

riscv64
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.

Ngôn ngữ chính
JavaScript
Star
124k
Fork
38.1k
Merge trung bình
4 ngày 21 giờ
Pull request đã merge (30 ngày)
242

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của nodejs/node

Tất cả issue của nodejs/node

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.