darktable-org / darktable-org/darktable

view change race condition may cause crash in color harmony buttons

Open
#20,529 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

no-issue-activity
Dominant language
C
Stars
13.1k
Forks
1.4k
Avg merge
22h 14m
Merged PRs (30d)
198

Description

See this report from #20489.

Imported some images and opened 1 in darkroom. Histogram was in waveform with no buttons displayed. When I hovered the two areas "highlighted" for adjusting exposure and black point. I tried clicking around in case the buttons were there but just not visible with no success. However when I exited darkroom I got a segfault Here's the log from the run:

dump.txt

and here's the backtrace file

darktable_bt_Y74ZL3.txt

Let me know what you'd like me to try...

Originally posted by @wpferguson in #20489

More notes here:

RE the crash, relevant from backtrace:

#4  _color_harmony_state_changed (widget=0x62a69b14e5c0, flags=<optimized out>, self=0x62a69d811808) at /home/bill/src/darktable/development/20489_scopes_buttons/src/libs/scopes/vectorscope.c:1061
        d = 0x0
        new_flags = GTK_STATE_FLAG_DIR_LTR
        prior = <optimized out>

This is happening in the d->harmony_prelight reference:

static void _color_harmony_state_changed(GtkWidget *widget,
GtkStateFlags flags,
dt_scopes_mode_t *const self)
{
dt_print_ext("_color_harmony_state_changed widget %p self %p self->data %p", widget, self, self->data);
dt_scopes_vec_t *const d = self->data;
GtkStateFlags new_flags = gtk_widget_get_state_flags(widget);
const dt_color_harmony_type_t prior = d->harmony_prelight;

I'm confused why d is NULL. This callback should only be called once histogram's gui_init is called at startup, which calls _vec_gui_init which sets self->data then sets up the callback. Even if you start dt by loading an image and going straight to darkroom mode, that should be the sequence. We shouldn't be freeing self->data until histogram's gui_cleanup is called at shutdown, which calls _vec_gui_cleanup.

See further notes in #20489. It's not clear if this is fixed via #20524 or if this has to do with a race condition while changing views.

Making this issue, so there is a note to follow up...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the backtrace and the _color_harmony_state_changed callback in libs/scopes/vectorscope.c, especially the self->data and harmony_prelight references. Review the related discussion in #20489 and possible changes in #20524, then reproduce the view-change and darkroom-exit sequence described in the report. Done means the reported segfault is reproduced or ruled out and the callback no longer accesses invalid state during cleanup.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
desktop, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.