Skip to content

Commit 0b9f19a

Browse files
authored
Revert "[compiler-rt] Avoid generating coredumps when piped to a tool" (#85390)
This reverts commit 27e5312. This commit broke some bots: - clang-aarch64-sve-vla https://lab.llvm.org/buildbot/#/builders/197/builds/13609 - clang-aarch64-sve-vls https://lab.llvm.org/buildbot/#/builders/184/builds/10988 - clang-aarch64-lld-2stage https://lab.llvm.org/buildbot/#/builders/185/builds/6312 #83701
1 parent 0ae76a7 commit 0b9f19a

File tree

2 files changed

+2
-24
lines changed

2 files changed

+2
-24
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,7 @@ static void setlim(int res, rlim_t lim) {
104104

105105
void DisableCoreDumperIfNecessary() {
106106
if (common_flags()->disable_coredump) {
107-
rlimit rlim;
108-
CHECK_EQ(0, getrlimit(RLIMIT_CORE, &rlim));
109-
// On Linux, if the kernel.core_pattern sysctl starts with a '|' (i.e. it
110-
// is being piped to a coredump handler such as systemd-coredumpd), the
111-
// kernel ignores RLIMIT_CORE (since we aren't creating a file in the file
112-
// system) except for the magic value of 1, which disables coredumps when
113-
// piping. 1 byte is too small for any kind of valid core dump, so it
114-
// also disables coredumps if kernel.core_pattern creates files directly.
115-
// While most piped coredump handlers do respect the crashing processes'
116-
// RLIMIT_CORE, this is notable not the case for Debian's systemd-coredump
117-
// due to a local patch that changes sysctl.d/50-coredump.conf to ignore
118-
// the specified limit and instead use RLIM_INFINITY.
119-
//
120-
// The alternative to using RLIMIT_CORE=1 would be to use prctl() with the
121-
// PR_SET_DUMPABLE flag, however that also prevents ptrace(), so makes it
122-
// impossible to attach a debugger.
123-
rlim.rlim_cur = Min<rlim_t>(SANITIZER_LINUX ? 1 : 0, rlim.rlim_max);
124-
CHECK_EQ(0, setrlimit(RLIMIT_CORE, &rlim));
107+
setlim(RLIMIT_CORE, 0);
125108
}
126109
}
127110

compiler-rt/test/sanitizer_common/TestCases/corelimit.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ int main() {
1010
getrlimit(RLIMIT_CORE, &lim_core);
1111
void *p;
1212
if (sizeof(p) == 8) {
13-
#ifdef __linux__
14-
// See comments in DisableCoreDumperIfNecessary().
15-
assert(lim_core.rlim_cur == 1);
16-
#else
17-
assert(lim_core.rlim_cur == 0);
18-
#endif
13+
assert(0 == lim_core.rlim_cur);
1914
}
2015
return 0;
2116
}

0 commit comments

Comments
 (0)