Skip to content

Fix dt_cache_get_with_caller to not crash with invalid argument - #21960

Open
victoryforce wants to merge 2 commits into
darktable-org:masterfrom
victoryforce:guard-against-NULL-cache-argument
Open

Fix dt_cache_get_with_caller to not crash with invalid argument#21960
victoryforce wants to merge 2 commits into
darktable-org:masterfrom
victoryforce:guard-against-NULL-cache-argument

Conversation

@victoryforce

Copy link
Copy Markdown
Collaborator

The problem this PR fixes is actually happening to users, as confirmed by many issues over the years, including the latest release. Due to some yet-to-be-discovered root cause, some calls to functions that return a cache key (dt_cache_get_with_caller or dt_cache_get, which are just a wrapper to hide irrelevant arguments) pass NULL as the cache reference argument to that function.

Unprepared for the possibility of such an erroneous call, the function was not protected against this and, without checking, dereferenced the received argument, which led to a crash.

Issues: #17114, #17848, #20976, #21108, #21790.

This problem could also be the cause of crashes in other issues that described data-dependent crashes, i.e., which did not occur when running with an empty configuration. However, without a provided backtrace pointing to dt_cache_get_with_caller before the crash, it's impossible to know for sure.

What this PR does:

  • Avoids the specific crash described above. Logs information from where the bad call was made.

What this PR doesn't do:

  • It doesn't guarantee that the crash won't happen somewhere else after we fix this specific thing.
  • It doesn't fix the root cause (which remains unknown) of why the call with the invalid parameter occurred.

So far, I can't even be sure if this situation can be reproduced deterministically when importing specific files whose features trigger the buggy path in the program. I can't rule out that this happens due to a race condition, for example. None of the issues I read had this information. Even where the bug reporter provided the alleged culprit files, he did not write that he tried and repeatedly got the program to crash after importing the files.

For 5.6.1, it eliminates crashes that are actually happening to users and is obviously safe.

@victoryforce victoryforce linked an issue Aug 22, 2026 that may be closed by this pull request
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash (unhandled exception) when launching

1 participant