@@ -51,10 +51,18 @@ public struct ExitTest: Sendable, ~Copyable {
51
51
EXCEPTION_DEFAULT,
52
52
THREAD_STATE_NONE
53
53
)
54
- #elseif os(Linux) || os(FreeBSD)
55
- // On Linux and FreeBSD, disable the generation of core files (although they
56
- // will often be disabled by default.) If a particular Linux distro performs
57
- // additional crash diagnostics, we may want to special-case them as well if we can.
54
+ #elseif os(Linux)
55
+ // On Linux, disable the generation of core files. They may or may not be
56
+ // disabled by default; if they are enabled, they significantly slow down
57
+ // the performance of exit tests. The kernel special-cases RLIMIT_CORE=1 to
58
+ // mean core files should not be generated even if they are being written to
59
+ // a pipe instead of a regular file; that gets us our performance back.
60
+ // SEE: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/coredump.c#n610
61
+ var rl = rlimit ( rlim_cur: 1 , rlim_max: 1 )
62
+ _ = setrlimit ( CInt ( RLIMIT_CORE . rawValue) , & rl)
63
+ #elseif os(FreeBSD)
64
+ // As with Linux, disable the generation core files. FreeBSD does not, as
65
+ // far as I can tell, special-case RLIMIT_CORE=1.
58
66
var rl = rlimit ( rlim_cur: 0 , rlim_max: 0 )
59
67
_ = setrlimit ( CInt ( RLIMIT_CORE . rawValue) , & rl)
60
68
#elseif os(Windows)
@@ -63,6 +71,8 @@ public struct ExitTest: Sendable, ~Copyable {
63
71
// these functions, so we don't attempt to preserve any previously-set bits.
64
72
_ = SetErrorMode ( UINT ( SEM_NOGPFAULTERRORBOX) )
65
73
_ = WerSetFlags ( DWORD ( WER_FAULT_REPORTING_NO_UI) )
74
+ #else
75
+ #warning("Platform-specific implementation missing: unable to disable crash reporting")
66
76
#endif
67
77
}
68
78
0 commit comments