From 9850628e1bfd7a3d88fb0f16d58581ea05e45647 Mon Sep 17 00:00:00 2001 From: LuisBiceps <54749472+LuisBiceps@users.noreply.github.com> Date: Fri, 9 Oct 2026 01:20:58 +0800 Subject: [PATCH] test(libc): reset errno after the worker thread in guest_errors guest_errors sets errno to 13 and checks at the end that the strerror_r calls left it alone, but a std::thread is created and joined in between. Guest errno is the host's errno. Since glibc 2.42, pthread_create first tries madvise(MADV_GUARD_INSTALL) for the new thread's stack guard. Kernels before 6.13, including WSL2's 6.6, reject it with EINVAL, and glibc falls back to mprotect with errno left at EINVAL. POSIX leaves errno unspecified after a successful call, so the test aborts on Ubuntu 26.04 (glibc 2.43) under WSL2 without anything being wrong. Check errno right after the strerror calls, and set it to 13 again after the join, so every errno check covers only strerror and strerror_r. --- core/libs/tests/GuestErrors.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/libs/tests/GuestErrors.cpp b/core/libs/tests/GuestErrors.cpp index 453dae221..52160d562 100644 --- a/core/libs/tests/GuestErrors.cpp +++ b/core/libs/tests/GuestErrors.cpp @@ -15,10 +15,12 @@ int main() { Require(*__error_nid_postfix() == 13); Require(std::strcmp(strerror_nid_postfix(78), "Function not implemented") == 0); char* parent = strerror_nid_postfix(22); + Require(*__error_nid_postfix() == 13); std::thread worker([] { Require(std::strcmp(strerror_nid_postfix(45), "Operation not supported") == 0); }); worker.join(); + *__error_nid_postfix() = 13; Require(std::strcmp(parent, "Invalid argument") == 0); char buffer[128]; for (int error = 0; error <= 96; ++error) {