Skip to content

Popovers never outlive their parent (crash in gtk_widget_unparent) - #89

Open
marcin-koziol wants to merge 1 commit into
BurningTreeC:mainfrom
marcin-koziol:popover-parent-lifetime
Open

marcin-koziol wants to merge 1 commit into
BurningTreeC:mainfrom
marcin-koziol:popover-parent-lifetime

Conversation

@marcin-koziol

Copy link
Copy Markdown

What happened

FaderFrame crashed with SIGSEGV in the main loop. The stack ran through an idle callback into gtk_widget_unparent, and the callback was the one plugin_browser::ask_name queues for its popover (symbolized from a release build with debug info):

libgtk-4.so.1 (gtk_widget_unparent+0x85)
faderframe   drop_glue<gtk4::Popover> … plugin_browser::ask_name::{closure#3}  plugin_browser.rs:600
libglib-2.0  … g_main_context_iteration

Cause

Popovers the shell parents by hand were unparented in an idle callback after they closed. The plugin browser's name prompt is parented to a category row in the sidebar, and the sidebar is rebuilt when favourites change, a plugin check finishes or a rescan completes. When that happened while the prompt was open, the row was freed and the popover kept pointing at it, so unparenting it later crashed GTK.

Fix

canvas::attach_popover parents a transient popover for as long as it is shown. It unparents the popover once it closes, or immediately when the parent is destroyed, whichever comes first, so the idle callback then finds nothing to do.

Every popover the shell parents by hand now uses it:

  • the canvas menus and text prompts;
  • the plugin browser's name prompt;
  • the MIDI learn menu;
  • the toggles' submenus;
  • the plugin window's parameter menu.

Popovers in the Windows crash reports (IME code reached during a menu popup or a dock tab click) are created on the same paths. This change may help there too, but that is not verified.

Tests

  • a_popover_outlives_its_parent_row_safely (an --ignored GTK test, like the other display tests in faderframe-ui): the popover's parent row is removed while the popover is open; the popover is then closed and the main loop run.
    • With the fix the popover is unparented together with the row and closing it is harmless.
    • Without it, parent() returns the freed row and the test fails there.
  • clippy -D warnings on faderframe-ui is clean, and so is fmt --check.

🤖 Generated with Claude Code

A popover was unparented in an idle callback after it closed. When its
parent went while it was open — the plugin browser's category row, with
the sidebar rebuilt by a favourite, a plugin check or a rescan — the
popover kept pointing at the freed row, and gtk_widget_unparent crashed
(SIGSEGV in the idle callback, from plugin_browser's ask_name).

canvas::attach_popover parents a transient popover for as long as it is
shown: unparented once it closes, or right when its parent is destroyed,
whichever comes first; the idle then finds nothing to do. Every popover
the shell parents by hand uses it: the canvas menus and text prompts,
the plugin browser's name prompt, MIDI learn, the toggles' submenus and
the plugin window's parameter menu.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

2 participants