From f1adb4aca5cec64c901a7933332a64bfa7688a19 Mon Sep 17 00:00:00 2001 From: Kofa Date: Tue, 29 Sep 2026 04:44:38 +0000 Subject: [PATCH] common: restore OpenMP thread limit after GraphicsMagick init GraphicsMagick resets the main thread's OpenMP limit to the CPU count. With --threads set lower, darktable-cli can then run more threads than its per-thread buffers hold. Reapply the requested limit after Magick initialization. Fixes #22436 --- RELEASE_NOTES.md | 3 +++ src/common/darktable.c | 7 +++++++ src/tests/integration | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 9c37de92d4..3b5bdb862f 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -513,6 +513,9 @@ changes (where available). one, which slightly changed the colors along the right edge of the image. +- Fixed darktable-cli crashing when `--threads` was set below the + number of CPUs. + ## Lua ### API Version diff --git a/src/common/darktable.c b/src/common/darktable.c index a9e9a56ecf..16f2392518 100644 --- a/src/common/darktable.c +++ b/src/common/darktable.c @@ -2062,6 +2062,13 @@ int dt_init(int argc, MagickWandGenesis(); #endif +#ifdef _OPENMP + // GraphicsMagick's init resets the thread count to the number of CPUs, + // overriding --threads. dt_alloc_perthread() pools are sized by + // dt_get_num_threads(), so a larger team would write past their end. + omp_set_num_threads(darktable.num_openmp_threads); +#endif + #ifdef HAVE_LIBHEIF dt_splash_screen_set_progress(_("initializing libheif")); heif_init(NULL); diff --git a/src/tests/integration b/src/tests/integration index 9bb0d89bcb..0ba30f94db 160000 --- a/src/tests/integration +++ b/src/tests/integration @@ -1 +1 @@ -Subproject commit 9bb0d89bcb85cd5acfe64ca98738d0878ab5ecb2 +Subproject commit 0ba30f94dbd0a5adbad69a228e6589d99cd00cef