Skip to content

21918: ashift: lock when reading buffer geometry from GTK thread - #22198

Open
kofa73 wants to merge 1 commit into
darktable-org:masterfrom
kofa73:fix/21918
Open

kofa73 wants to merge 1 commit into
darktable-org:masterfrom
kofa73:fix/21918

Conversation

@kofa73

@kofa73 kofa73 commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

ashift: read preview geometry under gui_lock

Fixes #21918

The issue:
The preview pipe writes its buffer geometry under gui_lock, but several GUI readers access it without locking. A concurrent update can mix dimensions from different preview runs, affecting the crop outline or automatic crop.
The issue was found by source analysis, @wpferguson then reported high reproduction rate via Lua (he had run into the issue earlier).

The fix:

  • Use the dt_iop_gui_enter_critical_section() / dt_iop_gui_leave_critical_section() pair to acquire and release gui_lock.
  • Read buffer availability, dimensions, and offsets together under the lock into a new dt_iop_ashift_bufgeom_t struct, then use that local snapshot.
  • Apply the same locking to the isflipped readers.

The new helpers release the lock before fitting, drawing, or history updates.

Testing:
no longer reproduces with the Lua script

AI:
Coded by Claude Code; reviewed by Codex.

@kofa73
kofa73 requested a review from ralfbrown September 8, 2026 05:07

@ralfbrown ralfbrown left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable on a quick skim. I'll give it a try tomorrow.

@kofa73
kofa73 force-pushed the fix/21918 branch 2 times, most recently from 1b2b673 to 08ea15a Compare September 8, 2026 19:34
@kofa73

kofa73 commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased, no other change

@TurboGit TurboGit added this to the 5.8 milestone Sep 8, 2026
@TurboGit TurboGit added bugfix pull request fixing a bug priority: medium core features are degraded in a way that is still mostly usable, software stutters labels Sep 8, 2026
@kofa73
kofa73 requested a review from TurboGit September 15, 2026 18:59
@kofa73

kofa73 commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator Author

@ralfbrown : please check if you can find the time.

@kofa73

kofa73 commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator Author

Will conflict with #22332 , but I'll clean up whichever is merged later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix pull request fixing a bug priority: medium core features are degraded in a way that is still mostly usable, software stutters

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ashift reads its buffer geometry on the GTK thread without the lock the pipe writes it under

3 participants