Skip to content

masks: don't let mask manager rows hand out stale module pointers - #22055

Draft
da-phil wants to merge 1 commit into
darktable-org:masterfrom
da-phil:pl/prevent_mask_manager_from_handing_out_stale_module_pointers
Draft

masks: don't let mask manager rows hand out stale module pointers#22055
da-phil wants to merge 1 commit into
darktable-org:masterfrom
da-phil:pl/prevent_mask_manager_from_handing_out_stale_module_pointers

Conversation

@da-phil

@da-phil da-phil commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

The treeview caches a raw dt_iop_module_t* per row, but rows outlive modules: gui_update() only rebuilds the store when the shape structure hash changes, while modules are freed when an instance is deleted or the image changes. Deleting a shape then passed a dangling pointer to dt_masks_form_remove() and crashed in dt_iop_is_hidden().

  • _lib_masks_get_values(): only return a module still present in dev->iop
  • _tree_delete_shape(): stop clobbering the row's module with the one of the previous row
  • _forms_structure_hash(): include the modules and their mask ids so a changed module set forces a rebuild instead of an in-place refresh

Speculatively fixes #22050

Disclaimer: this change was co-created with Claude.

The treeview caches a raw dt_iop_module_t* per row, but rows outlive
modules: gui_update() only rebuilds the store when the shape structure
hash changes, while modules are freed when an instance is deleted or the
image changes. Deleting a shape then passed a dangling pointer to
dt_masks_form_remove() and crashed in dt_iop_is_hidden().

- _lib_masks_get_values(): only return a module still present in dev->iop
- _tree_delete_shape(): stop clobbering the row's module with the one of
  the previous row
- _forms_structure_hash(): include the modules and their mask ids so a
  changed module set forces a rebuild instead of an in-place refresh
@da-phil
da-phil force-pushed the pl/prevent_mask_manager_from_handing_out_stale_module_pointers branch from 48974d6 to 1c65474 Compare August 29, 2026 19:49
@ralfbrown ralfbrown added bugfix pull request fixing a bug scope: UI user interface and interactions labels Aug 29, 2026
@TurboGit

Copy link
Copy Markdown
Member

Since mask manager will be removed in 5.8 and replaced by the new flexi masking maybe this is just not necessary.

@da-phil

da-phil commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

I guess it also depends if that gets into the way of the flexi masking development, like constantly producing merge conflicts. If not, I don't see why we should not make sure existing bugs are fixed until the module can be fully replaced by a new one. What do you think about that?

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 scope: UI user interface and interactions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash when deleting mask in mask manager

3 participants