After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 581110 - Handlebox widget uses static variables, crashes in multidisplay usage.
Handlebox widget uses static variables, crashes in multidisplay usage.
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: Other
2.16.x
Other All
: Normal critical
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2009-05-02 16:44 UTC by Jan D.
Modified: 2011-10-01 07:27 UTC
See Also:
GNOME target: ---
GNOME version: 2.25/2.26


Attachments
Program showing the bug. (2.01 KB, text/plain)
2009-08-05 10:02 UTC, Jan D.
Details

Description Jan D. 2009-05-02 16:44:32 UTC
Steps to reproduce:
1. Create a top level window with a detachable toolbar (i.e. a handlebox).
2. Detach the toolbar.
3. Close the display the window is on.
4. Create an indentical window as in 1), but on another display.
5. Detach the toolbar => crash in handlebox.


Stack trace:
This is a stack trace from Emacs which has the capability to do the steps above.  The problem comes from gtkhandlebox.c which uses static variables and thus assumes there is only one display.  gtkhandlebox.c contains:

static GtkWidget *
gtk_handle_box_get_invisible (void)
{
  static GtkWidget *handle_box_invisible = NULL;

  if (!handle_box_invisible)
    {
      handle_box_invisible = gtk_invisible_new ();
      gtk_widget_show (handle_box_invisible);
    }
  
  return handle_box_invisible;
}

The handle_box_invisible points to the GtkWidget created on the first display, but it gets used even after that display is closed.  Stack trace from emacs and gtk 2.16.1:

  • #0 IA__gdk_pointer_grab
    at gdkmain-x11.c line 211
  • #1 gtk_handle_box_button_press
    at gtkhandlebox.c line 1117
  • #2 _gtk_marshal_BOOLEAN__BOXED
    at gtkmarshalers.c line 84
  • #3 g_type_class_meta_marshal
    at gclosure.c line 878
  • #4 IA__g_closure_invoke
    at gclosure.c line 767
  • #5 signal_emit_unlocked_R
    at gsignal.c line 3285
  • #6 IA__g_signal_emit_valist
    at gsignal.c line 2990
  • #7 IA__g_signal_emit
    at gsignal.c line 3037
  • #8 gtk_widget_event_internal
    at gtkwidget.c line 4761
  • #9 IA__gtk_widget_event
    at gtkwidget.c line 4558
  • #10 IA__gtk_propagate_event
    at gtkmain.c line 2396
  • #11 IA__gtk_main_do_event
    at gtkmain.c line 1586
  • #12 gdk_event_dispatch
    at gdkevents-x11.c line 2364
  • #13 g_main_dispatch
    at gmain.c line 1814
  • #14 IA__g_main_context_dispatch
    at gmain.c line 2367
  • #15 g_main_context_iterate
    at gmain.c line 2448
  • #16 IA__g_main_context_iteration
    at gmain.c line 2511
  • #17 IA__gtk_main_iteration
    at gtkmain.c line 1293
  • #18 XTread_socket
    at xterm.c line 7252





Other information:
Comment 1 Matthias Clasen 2009-05-04 02:32:16 UTC
Should be fixed now.
Comment 2 Jan D. 2009-08-05 09:37:08 UTC
This is not fixed right.
When the first display is closed, all display-related variables becomes invalid.
For example, GC:s.  So when gtk_invisible_set_screen (as introduced by this fix) is called the second time, it crashes, because it tries to free resources from the first display.  Note that first and second disply can be the same display, it just takes a close and reopen of the display to trigger this bug.

The static variable really must be a per-display resource that is freed when the display is closed.

Here is a new backtrace from Gtk+ 2.16.2:
  • #0 XFreeGC
    from /usr/lib/libX11.so.6
  • #1 gdk_gc_x11_finalize
    at gdkgc-x11.c line 84
  • #2 IA__g_object_unref
    at gobject.c line 2421
  • #3 gtk_gc_destroy
    at gtkgc.c line 191
  • #4 IA__g_cache_remove
    at gcache.c line 169
  • #5 IA__gtk_gc_release
    at gtkgc.c line 97
  • #6 gtk_style_real_unrealize
    at gtkstyle.c line 2090
  • #7 IA__g_cclosure_marshal_VOID__VOID
    at gmarshal.c line 77
  • #8 g_type_class_meta_marshal
    at gclosure.c line 878
  • #9 IA__g_closure_invoke
    at gclosure.c line 767
  • #10 signal_emit_unlocked_R
    at gsignal.c line 3177
  • #11 IA__g_signal_emit_valist
    at gsignal.c line 2980
  • #12 IA__g_signal_emit
    at gsignal.c line 3037
  • #13 IA__gtk_style_detach
    at gtkstyle.c line 798
  • #14 gtk_widget_real_unrealize
    at gtkwidget.c line 8050
  • #15 IA__g_cclosure_marshal_VOID__VOID
    at gmarshal.c line 77
  • #16 g_type_class_meta_marshal
    at gclosure.c line 878
  • #17 IA__g_closure_invoke
    at gclosure.c line 767
  • #18 signal_emit_unlocked_R
    at gsignal.c line 3285
  • #19 IA__g_signal_emit_valist
    at gsignal.c line 2980
  • #20 IA__g_signal_emit
    at gsignal.c line 3037
  • #21 IA__gtk_widget_unrealize
    at gtkwidget.c line 3373
  • #22 IA__gtk_invisible_set_screen
    at gtkinvisible.c line 185
  • #23 gtk_handle_box_button_press
    at gtkhandlebox.c line 1082

Comment 3 Jan D. 2009-08-05 10:02:46 UTC
Created attachment 139930 [details]
Program showing the bug.

To reproduce the bug, compile the program and run it. Then

1. Detatch the tool bar.
2. Press the "Close/Reopen" button.
3. Detach the tool bar again => crash.
Comment 4 Emmanuele Bassi (:ebassi) 2011-10-01 07:27:40 UTC
the handlebox widget has been deprecated in gtk 3.1.