GNOME Bugzilla – Bug 752208
gnome-terminal may crash when I right-click on a selection
Last modified: 2015-07-31 13:18:15 UTC
This problem starts happening recently, but I still cannot find a reliable way to reproduce it. The crash usually happens when I select some text and right-click on it. When this problem happens, I can't see the popup menu and a new message is found in dmesg because gnome-terminal-server crashes with SIGBUS. Here is the backtrace generated from a core dump:
+ Trace 235247
Some older backtraces: http://fpaste.org/239699/43599102/ http://fpaste.org/239708/14359942/
In frame #2, The object that data->attach_widget points to is invalid. (gdb) print *(data->attach_widget) $1 = {parent_instance = {g_type_instance = {g_class = 0xaaaaaaaaaaaaaaaa}, ref_count = 2863311530, qdata = 0xaaaaaaaaaaaaaaaa}, priv = 0xaaaaaaaaaaaaaaaa}
Does reverting commit 67afb95efd64f29d62ebd32853276a76a5d0760f fix this?
After using gnome-terminal for several hours, I hope it is fixed. I don't see any crash caused by right-clicks after reverting the commit.
I found a reliable way to reproduce: 1. Open gnome-terminal 2. Open a new tab 3. Select some text 4. Right click 5. Dismiss the popup menu 6. Close the tab 7. Select text in the initial tab 8. Right click This seems to crash every time for me. The reason is that after you have attached a menu to a widget, there are two references to the popup menu; one from the GtkUiManager, and one from the widget the menu is attached to. When the widget the menu is attached to is destroyed, it removes its references and assumes it was the sole owner of the menu, assuming it was destroyed. When we then refetch the menu from GtkUiManager, we see that it is still attached to something, and then we try to detach it; which is why it fails: it tries to detach from something that was destoryed, and as a result tries to dereference the freed instance. I see two possible solutions: 1. Move this bug to GTK+, making GTK menu attachment able to deal with not being the sole owner of a menu. 2. Do a reference dance in terminal-window for example: menu = get(); ref(menu); if (attached(menu)) detach(menu); attach(menu); unref(menu); unref(menu); CC:ing mclasen. Is this something the GTK+ API is expected to handle, i.e. should we move this bug over there?
(In reply to Jonas Ådahl from comment #4) > I found a reliable way to reproduce: > > 1. Open gnome-terminal > 2. Open a new tab > 3. Select some text > 4. Right click > 5. Dismiss the popup menu > 6. Close the tab > 7. Select text in the initial tab > 8. Right click > I can reproduce the problem using the above steps.
Ting-Wei, could you test the GTK+ patch in bug 752761? It fixes the issue you reported when I reproduce using the above steps.
Yes, it fixes the problem.
Can we close this now?
Yes, the gtk+ fix is already pushed, so I close it now.