Source: clickhouse Version: 18.16.1+ds-7.2 Severity: normal Tags: patch Dear maintainer,
when building in pbuilder, I get test suit errors. This is due that in a pbuilder environment disables core dumps. However, clickhouse tries to set maximium core size to 1GiB, which does not work, as setrlimit cannot increase the limit. The attached patch fixes that: It will first check if the user has configured something, and if so, it will try to set the configuration value (and fail if it cannot.) If the user has not set a value in configuration, it will either set it to 1GiB (as before) or the maximum allowed value. As this code is used in the server code, the situation where this can happen is not limited to pbuilder, but can also happen if an admin turns off or limits core dumps less than 1GiB and not adapt config accordingly. -- tobi -- System Information: Debian Release: bookworm/sid APT prefers stable-security APT policy: (500, 'stable-security'), (500, 'unstable'), (500, 'testing'), (500, 'stable'), (100, 'bullseye-fasttrack'), (100, 'bullseye-backports-staging'), (1, 'experimental') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 5.19.0-2-amd64 (SMP w/12 CPU threads; PREEMPT) Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE not set Shell: /bin/sh linked to /usr/bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled
--- a/libs/libdaemon/src/BaseDaemon.cpp +++ b/libs/libdaemon/src/BaseDaemon.cpp @@ -905,9 +905,17 @@ if (getrlimit(RLIMIT_CORE, &rlim)) throw Poco::Exception("Cannot getrlimit"); /// 1 GiB by default. If more - it writes to disk too long. - rlim.rlim_cur = config().getUInt64("core_dump.size_limit", 1024 * 1024 * 1024); + auto wanted = config().getUInt64("core_dump.size_limit", 0); + if(!wanted) { + // configuration is not present -- default to 1 GiB, but only if current rlimits allows it. + wanted = std::min(1024*1024*1024, rlim.rlim_cur); + wanted = std::min(wanted, rlim.rlim_max); + } - if (setrlimit(RLIMIT_CORE, &rlim)) + auto orig = rlim.rlim_cur; + rlim.rlim_cur = wanted; + + if (orig != wanted && setrlimit(RLIMIT_CORE, &rlim)) { std::string message = "Cannot set max size of core file to " + std::to_string(rlim.rlim_cur); #if !defined(ADDRESS_SANITIZER) && !defined(THREAD_SANITIZER) && !defined(MEMORY_SANITIZER) && !defined(SANITIZER) && !defined(__APPLE__)
signature.asc
Description: PGP signature