fix: avoid double-borrow panic on rapid Ctrl+Tab tab switching - #113
Open
ferdinankurnian wants to merge 1 commit into
Open
fix: avoid double-borrow panic on rapid Ctrl+Tab tab switching#113ferdinankurnian wants to merge 1 commit into
ferdinankurnian wants to merge 1 commit into
Conversation
…e-borrow panic on rapid tab cycling
Author
|
Here's the recording confirming the fix, rapid Ctrl+Tab, no crash: recording_2026-07-11_17-14-12.mp4 |
bvolpato
approved these changes
Jul 12, 2026
bvolpato
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Scoped RefCell borrow removes GTK reentrancy panic while preserving focus behavior.
| .find(|entry| entry.id == tab_id) | ||
| .map(TabFocusTarget::from_entry); | ||
|
|
||
| (focus_target, content_stack.child_by_name(tab_id).is_some()) |
Contributor
There was a problem hiding this comment.
Non-blocking: move child_by_name() below this scope. Current comment says content_stack is untouched until ts drops, but this query still runs under borrow_mut(). It is likely signal-free; keeping all stack calls outside makes reentrancy boundary explicit.
bvolpato
approved these changes
Jul 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a crash caused by a double-borrow panic on
TabState'sRefCellwhen rapidly switching tabs with Ctrl+Tab.Root cause
activate_tab()inpane.rsheldtab_state.borrow_mut()across the call tocontent_stack.set_visible_child_name(tab_id). That GTK call synchronously fires an unmap/map signal cascade on the old and new tab content — including hover/crossing signals on the terminal surface, whose callback callstab_rename_active(&tab_state), which needstab_state.borrow().A single tab switch usually completes (and drops the borrow) before the next signal fires, so it goes unnoticed. But pressing Ctrl+Tab rapidly (2-4x in quick succession) can start a second
activate_tab()call while the first switch's unmap cascade is still resolving, causing the reentrant.borrow()to panic while the outer.borrow_mut()is still held — and since this happens inside a GTK/glib signal callback (FFI boundary), the panic can't unwind and the process aborts (SIGABRT).Fix
Narrowed the
borrow_mut()scope so it's dropped beforecontent_stack.set_visible_child_name()is called, removing the reentrancy window.Testing
limux-bin) before applying the fix — rapid Ctrl+Tab (2-4 presses) crashed every timeBuild Linux Release Packagesworkflow, downloaded and ran the resulting build locally — rapid Ctrl+Tab no longer crashesRust Qualityworkflow (build, clippy, fmt) passes on the fix commitFixes #111