From a7be43f30296581af735e4be9de27aa2acda1d06 Mon Sep 17 00:00:00 2001 From: Bingwu Zhang Date: Sat, 1 Mar 2025 10:45:14 +0800 Subject: [PATCH 1/2] LoongArch: Remove unused va_list to VMError::report_and_die VMError::report_and_die provides an overload that takes a variable-length argument as the last argument, so we can use it instead of the overload taking va_list as the last argument. The implementation detail of va_list is compiler-defined and constructing a va_list manually is not standardized which may not work as expected. This should resolve the warning saying that report_and_die uses the uninitialized variable of va_dummy. Signed-off-by: Bingwu Zhang --- src/hotspot/os_cpu/linux_loongarch/os_linux_loongarch.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/hotspot/os_cpu/linux_loongarch/os_linux_loongarch.cpp b/src/hotspot/os_cpu/linux_loongarch/os_linux_loongarch.cpp index 73c9e983e485f..90e4dc75814de 100644 --- a/src/hotspot/os_cpu/linux_loongarch/os_linux_loongarch.cpp +++ b/src/hotspot/os_cpu/linux_loongarch/os_linux_loongarch.cpp @@ -278,9 +278,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info, // End life with a fatal error, message and detail message and the context. // Note: no need to do any post-processing here (e.g. signal chaining) - va_list va_dummy; - VMError::report_and_die(thread, uc, nullptr, 0, msg, detail_msg, va_dummy); - va_end(va_dummy); + VMError::report_and_die(thread, uc, nullptr, 0, msg, detail_msg); ShouldNotReachHere(); } From 4b931e116196ab260e191a863db43b6fe3cd578e Mon Sep 17 00:00:00 2001 From: Bingwu Zhang Date: Sat, 1 Mar 2025 10:55:52 +0800 Subject: [PATCH 2/2] LoongArch: Avoid formatter injection The sixth argument of VMError::report_and_die is a formatting string, using detail_msg as the 6th arg leaves a location for formatter injecting, although it is hard to be used because almost all detail_msg point to static strings. This should resolve the Clang warning saying that the formatter string is not constant. Signed-off-by: Bingwu Zhang --- src/hotspot/os_cpu/linux_loongarch/os_linux_loongarch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/os_cpu/linux_loongarch/os_linux_loongarch.cpp b/src/hotspot/os_cpu/linux_loongarch/os_linux_loongarch.cpp index 90e4dc75814de..36cc37df20f38 100644 --- a/src/hotspot/os_cpu/linux_loongarch/os_linux_loongarch.cpp +++ b/src/hotspot/os_cpu/linux_loongarch/os_linux_loongarch.cpp @@ -278,7 +278,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info, // End life with a fatal error, message and detail message and the context. // Note: no need to do any post-processing here (e.g. signal chaining) - VMError::report_and_die(thread, uc, nullptr, 0, msg, detail_msg); + VMError::report_and_die(thread, uc, nullptr, 0, msg, "%s", detail_msg); ShouldNotReachHere(); }