From: Simon Marchi Date: Tue, 8 Oct 2024 15:52:41 +0000 (-0400) Subject: tests: disable coredumps in `conds-trigger` X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=73032b64928f7d593d64e2338c01d338c4a18782;p=babeltrace.git tests: disable coredumps in `conds-trigger` After adding some more tests in `conds-trigger`, some CI jobs would start to fail randomly while running that test, with the Jenkins runner process seemingly crashing. Digging a little bit revealed that many processes (including `systemd-coredump`) would get OOM-killed. What I think happens is that the many quickly crashing `conds-triggers` processes cause many `systemd-coredump` processes to get started, which causes too much memory to be consumed. It's just wasteful to generate core dumps while running this test anyway, so disable them. Use `setrlimit()` in the code path that we know is going to lead to a crash. I considered calling `ulimit -c 0` in the bash script that calls all this, but I would prefer to disable core dumps in the narrowest scope possible, so that we don't disable them for the code that's not supposed to crash. Change-Id: I69bf206cf0afed26f6db65e7fb7e70e9dbe7c053 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/13325 Reviewed-by: Kienan Stewart Reviewed-by: Philippe Proulx Tested-by: jenkins --- diff --git a/configure.ac b/configure.ac index 799df2f7..7be0a765 100644 --- a/configure.ac +++ b/configure.ac @@ -323,6 +323,7 @@ AC_CHECK_FUNCS([ \ munmap \ rmdir \ setenv \ + setrlimit \ socket \ strchr \ strdup \ diff --git a/tests/lib/conds/utils.cpp b/tests/lib/conds/utils.cpp index 657ffa00..cfa34c2f 100644 --- a/tests/lib/conds/utils.cpp +++ b/tests/lib/conds/utils.cpp @@ -17,6 +17,10 @@ #include "utils.hpp" +#ifdef HAVE_SETRLIMIT +# include +#endif /* HAVE_SETRLIMIT */ + CondTrigger::CondTrigger(const Type type, const std::string& condId, const bt2c::CStringView nameSuffix) noexcept : _mType {type}, @@ -35,6 +39,19 @@ SimpleCondTrigger::SimpleCondTrigger(std::function func, const Type type namespace { +void disableCoreDumps() noexcept +{ +#ifdef HAVE_SETRLIMIT + const rlimit limits {0, 0}; + const auto ret = setrlimit(RLIMIT_CORE, &limits); + + if (ret != 0) { + std::perror("setrlimit"); + std::exit(1); + } +#endif /* HAVE_SETRLIMIT */ +} + void listCondTriggers(const CondTriggers& condTriggers) noexcept { auto condTriggerArray = nlohmann::json::array(); @@ -80,6 +97,14 @@ void condMain(const bt2s::span argv, const CondTriggers& con */ g_unsetenv("BABELTRACE_EXEC_ON_ABORT"); + /* + * Since this program's purpose is to crash, it might generate + * a core dump every time it's started, which is not really + * useful (and has been known to overwhelm some CI workers). + * Disable them. + */ + disableCoreDumps(); + /* Find the trigger */ BT_ASSERT(argv.size() == 3);