tests: disable coredumps in `conds-trigger`
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 8 Oct 2024 15:52:41 +0000 (11:52 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 9 Oct 2024 02:56:57 +0000 (22:56 -0400)
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 <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/13325
Reviewed-by: Kienan Stewart <kstewart@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
configure.ac
tests/lib/conds/utils.cpp

index 799df2f79857250c8d57775b870bd2d06618d3f1..7be0a7654b046d2feb94da73d5f05c5fd7975e59 100644 (file)
@@ -323,6 +323,7 @@ AC_CHECK_FUNCS([ \
   munmap \
   rmdir \
   setenv \
+  setrlimit \
   socket \
   strchr \
   strdup \
index 657ffa00ecc050028abb4a62068779a63a9b22fd..cfa34c2fda6e3a910443d3ba51f54f997dbb7d04 100644 (file)
 
 #include "utils.hpp"
 
+#ifdef HAVE_SETRLIMIT
+#    include <sys/resource.h>
+#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<void()> 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<const char * const> 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);
 
This page took 0.026617 seconds and 4 git commands to generate.