Skip to content

Crash at startup due to race condition between OpenCL background job and dt_wb_presets_init #20770

@da-phil

Description

@da-phil

Is there an existing issue for this?

  • I checked and did not find my issue in the already reported ones

Describe the bug

I encountered a rather rare startup race condition between OpenCL background job and dt_wb_presets_init a couple of times in the past days and weeks, see gdb backtrace: darktable_bt_WNW7M3.txt

In darktable.c:1878-1887, the GUI startup path queues OpenCL detection as a background job on the system worker pool and then immediately continues to call dt_wb_presets_init(NULL).

dt_opencl_init (called by a worker thread) loads OpenCL vendor libraries (ICD loader, driver). These vendor libraries are known to call setlocale() internally.
setlocale() in glibc:

  • Acquires __libc_setlocale_lock
  • Frees and replaces internal locale data structures (including cached locale strings)

Meanwhile, the main thread is inside dcigettextguess_category_valuegetenv("LANGUAGE"). The glibc dcigettext code is not re-entrant with setlocale(): it caches locale state that can be freed mid-read when setlocale() runs concurrently, leading to a SIGSEGV. This does not happen in the non-GUI/CLI path (init_gui=0) because there dt_opencl_init is called synchronously before dt_wb_presets_init.

Darktable version: 5.5.0+915 (also happened in older versions from git)
OS: Ubuntu 24.04

Steps to reproduce

Start darktable.
I think the crash happened mostly when the system was already quite busy.

Expected behavior

No response

Logfile | Screenshot | Screencast

No response

Commit

No response

Where did you obtain darktable from?

darktable.org / GitHub release

darktable version

5.5.0+915 (also older versions were affected)

What OS are you using?

Linux

What is the version of your OS?

Ubuntu 24.04

Describe your system

System Details Report


Report details

  • Date generated: 2026-04-08 15:51:35

Hardware Information:

  • Hardware Model: TUXEDO TUXEDO InfinityBook Pro AMD Gen9
  • Memory: 32,0 GiB
  • Processor: AMD Ryzen™ 7 8845HS w/ Radeon™ 780M Graphics × 16
  • Graphics: AMD Radeon™ Graphics
  • Disk Capacity: 4,0 TB

Software Information:

  • Firmware Version: N.1.14A13
  • OS Name: Ubuntu 24.04.4 LTS
  • OS Build: (null)
  • OS Type: 64-bit
  • GNOME Version: 46
  • Windowing System: Wayland
  • Kernel Version: Linux 6.18.20-061820-generic

Are you using OpenCL GPU in darktable?

Yes

If yes, what is the GPU card and driver?

Radeon 780M iGPU

Please provide additional context if applicable. You can attach files too, but might need to rename to .txt or .zip

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    OpenCLRelated to darktable OpenCL codebug: pendingsomeone needs to start working on that

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions