mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-11-05 13:20:11 +00:00
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 <[email protected]>
This commit is contained in:
1 parent
31cbb55d75
commit
42191c0807
2 files changed
+19
-1
No files matched your search
@@ -14,6 +14,9 @@
|
||||
#include <pthread.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#ifdef __linux__
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
#include <unwind.h>
|
||||
|
||||
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]);
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
#include <string>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#ifdef __linux__
|
||||
#include <sys/prctl.h>
|
||||
#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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user