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); }