CRITICAL: Double-delete crash when closing tabs #2

Closed
opened 2026-09-07 15:00:48 +00:00 by x3 · 0 comments
Owner

Bug

close_tab_at() deleted the terminal, whose destructor called gtk_widget_destroy(vte_box_). GTK synchronously triggered the page-removed signal, invoking on_tab_close() which also tried to delete the same terminal.

Fix

Removed the page-removed signal handler entirely. Tab close is now handled explicitly without signal callbacks:

void SshClientWindow::close_tab_at(int idx) {
    // Find and disconnect first, THEN remove page
    SshTerminal* found = nullptr;
    for (auto it = terminals_.begin(); it != terminals_.end(); ++it) {
        if ((*it)->widget() == page) {
            found = *it;
            terminals_.erase(it);
            break;
        }
    }
    if (found) { found->disconnect(); delete found; }
    gtk_notebook_remove_page(GTK_NOTEBOOK(notebook_), idx);
}

Status: Fixed in commit 4a2b2ea

## Bug `close_tab_at()` deleted the terminal, whose destructor called `gtk_widget_destroy(vte_box_)`. GTK synchronously triggered the page-removed signal, invoking `on_tab_close()` which also tried to delete the same terminal. ## Fix Removed the `page-removed` signal handler entirely. Tab close is now handled explicitly without signal callbacks: ```cpp void SshClientWindow::close_tab_at(int idx) { // Find and disconnect first, THEN remove page SshTerminal* found = nullptr; for (auto it = terminals_.begin(); it != terminals_.end(); ++it) { if ((*it)->widget() == page) { found = *it; terminals_.erase(it); break; } } if (found) { found->disconnect(); delete found; } gtk_notebook_remove_page(GTK_NOTEBOOK(notebook_), idx); } ``` **Status:** Fixed in commit 4a2b2ea
x3 closed this issue 2026-09-07 16:58:14 +00:00
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: x3/x3-ssh#2