From 42191c0807cc0a3a1748996e660cacd3f6da59ea Mon Sep 17 00:00:00 2001 From: Hashaam Zafar Date: Thu, 15 Oct 2026 14:26:53 -0700 Subject: [PATCH] test(libc): keep intentional aborts away from the system crash handler guest_host_standard_error and exception_runtime fork children that end in SIGABRT on purpose. When kernel.core_pattern pipes cores to a handler, as Ubuntu's apport and systemd-coredump do, the kernel starts it for every dumpable crash even with RLIMIT_CORE at 0. apport takes about 1.1 s per crash here, so guest_host_standard_error spent 2.3 s waiting and timed out at its 10 s limit under parallel ctest load. Marking those children non-dumpable on Linux skips the handler: 2.29 s to 0.01 s and 1.17 s to 0.01 s, with the same SIGABRT and message checks. Co-Authored-By: Claude Opus 5.5 --- core/libs/tests/ExceptionRuntime.cpp | 6 ++++++ core/libs/tests/GuestHostStandardError.cpp | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/core/libs/tests/ExceptionRuntime.cpp b/core/libs/tests/ExceptionRuntime.cpp index 43dc8405c0..42079527da 100644 --- a/core/libs/tests/ExceptionRuntime.cpp +++ b/core/libs/tests/ExceptionRuntime.cpp @@ -14,6 +14,9 @@ #include #include #include +#ifdef __linux__ +#include +#endif #include extern "C" unsigned __cxa_uncaught_exceptions_nid_postfix(); @@ -172,6 +175,9 @@ void CheckDefaultTerminateMessage() { if (child == 0) { close(channel[0]); dup2(channel[1], 2); +#ifdef __linux__ + assert(prctl(PR_SET_DUMPABLE, 0) == 0); +#endif throw std::runtime_error(message); } close(channel[1]); diff --git a/core/libs/tests/GuestHostStandardError.cpp b/core/libs/tests/GuestHostStandardError.cpp index 72e2ea7025..bf4df157ce 100644 --- a/core/libs/tests/GuestHostStandardError.cpp +++ b/core/libs/tests/GuestHostStandardError.cpp @@ -11,6 +11,9 @@ #include #include #include +#ifdef __linux__ +#include +#endif extern "C" { FileStream* APS5_VABI freopen_nid_postfix(const char*, const char*, FileStream*); @@ -25,6 +28,12 @@ extern FileStream* __stderrp_nid_postfix; static void Require(bool value) { if (!value) std::abort(); } +static void SkipCrashHandler() { +#ifdef __linux__ + Require(::prctl(PR_SET_DUMPABLE, 0) == 0); +#endif +} + enum class Redirect { Duplicate, Reopen }; struct Outcome { @@ -56,7 +65,10 @@ static Outcome Run(Redirect redirect, const std::filesystem::path& probe, bool t ::close(host[1]); RedirectGuest(redirect, probe); std::fputs("host\n", stderr); - if (terminate) throw std::runtime_error("report kept"); + if (terminate) { + SkipCrashHandler(); + throw std::runtime_error("report kept"); + } if (redirect == Redirect::Reopen && fflush_nid_postfix(__stderrp_nid_postfix) != 0) ::_exit(71); ::_exit(0); }