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 778190 - Gdk-CRITICAL when GtkScrolledWindow unsetting scroll cursor
Gdk-CRITICAL when GtkScrolledWindow unsetting scroll cursor
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: GtkScrolledWindow
3.22.x
Other Linux
: Normal critical
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2017-02-05 03:42 UTC by Michael Gratton
Modified: 2018-05-02 18:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix Gdk-CRITICAL when GtkScrolledWindow unsetting scroll cursor (1.08 KB, patch)
2017-02-05 04:18 UTC, Michael Gratton
none Details | Review
Use weak ref to clear scrolled window (2.73 KB, patch)
2017-02-17 01:32 UTC, Michael Gratton
none Details | Review

Description Michael Gratton 2017-02-05 03:42:36 UTC
Since Bug 753202 landed, I'm now getting a Gdk-CRITICAL when GtkScrolledWindow  unsets the scroll cursor, after a WebKitGTK+ web view has been removed from the toplevel's widget hierarchy.

This may be related to how WebKitGTK+ handles events (see https://bugs.webkit.org/show_bug.cgi?id=136430#c1) but I think it might happen any time a widget with a GDK window has been removed before the cursor is unset. In any case, GtkScrolledWindow probably shouldn't crash.

Representative stack error and stack trace below, but looking at the value of priv->scroll_window, in the call to uninstall_scroll_cursor (#5 in the stack below), I get the following:

> (gdb) print priv->scroll_window.state
> $12 = GDK_WINDOW_STATE_WITHDRAWN
> (gdb) print priv->scroll_window.parent
> $13 = 0x0
> (gdb) print priv->scroll_window.destroyed
> $14 = 1

Maybe an an extra test should be added to uninstall_scroll_cursor? I'll look into getting a patch to fix this.

(geary:16329): Gdk-CRITICAL **: gdk_window_set_cursor: assertion 'GDK_IS_WINDOW (window)' failed

Thread 1 "geary" received signal SIGTRAP, Trace/breakpoint trap.
_g_log_abort (breakpoint=breakpoint@entry=1) at ././glib/gmessages.c:487
487	././glib/gmessages.c: No such file or directory.
(gdb) bt
  • #0 _g_log_abort
    at ././glib/gmessages.c line 487
  • #1 g_logv
    at ././glib/gmessages.c line 1296
  • #2 g_log
    at ././glib/gmessages.c line 1337
  • #3 g_return_if_fail_warning
  • #4 gdk_window_set_cursor
    at ././gdk/gdkwindow.c line 6558
  • #5 uninstall_scroll_cursor
    at ././gtk/gtkscrolledwindow.c line 3410
  • #6 gtk_scrolled_window_scroll_event
    at ././gtk/gtkscrolledwindow.c line 3571
  • #7 _gtk_marshal_BOOLEAN__BOXEDv
    at ././gtk/gtkmarshalers.c line 131
  • #8 _g_closure_invoke_va
    at ././gobject/gclosure.c line 867
  • #9 g_signal_emit_valist
    at ././gobject/gsignal.c line 3300
  • #10 g_signal_emit
    at ././gobject/gsignal.c line 3447
  • #11 gtk_widget_event_internal
    at ././gtk/gtkwidget.c line 7723
  • #12 propagate_event_up
    at ././gtk/gtkmain.c line 2567
  • #13 propagate_event
    at ././gtk/gtkmain.c line 2669
  • #14 gtk_main_do_event
    at ././gtk/gtkmain.c line 1890
  • #15 _gdk_event_emit
    at ././gdk/gdkevents.c line 73
  • #16 gdk_event_source_dispatch
    at ././gdk/x11/gdkeventsource.c line 367
  • #17 g_main_dispatch
    at ././glib/gmain.c line 3203
  • #18 g_main_context_dispatch
    at ././glib/gmain.c line 3856
  • #19 g_main_context_iterate
    at ././glib/gmain.c line 3929
  • #20 g_main_context_iteration
    at ././glib/gmain.c line 3990
  • #21 g_application_run
    at ././gio/gapplication.c line 2381
  • #22 _vala_main
    at /home/mjg/Projects/GNOME/geary/src/client/application/main.vala line 33
  • #23 __libc_start_main
    at ../csu/libc-start.c line 291
  • #24 _start

Comment 1 Michael Gratton 2017-02-05 04:18:30 UTC
Created attachment 344963 [details] [review]
Fix Gdk-CRITICAL when GtkScrolledWindow unsetting scroll cursor

Patch against gtk-3-22, can no longer seem to repro the problem with it applied.
Comment 2 Michael Gratton 2017-02-11 22:10:07 UTC
Definitely not WebKitGTK-related, just had basically the same happen after a GtkListBox was removed from a GtkScrolledWindow's viewport.

Any chance of getting a review for the patch?
Comment 3 Matthias Clasen 2017-02-15 23:12:10 UTC
Review of attachment 344963 [details] [review]:

::: gtk/gtkscrolledwindow.c
@@ +3411,3 @@
+        {
+          gdk_window_set_cursor (priv->scroll_window, priv->scroll_cursor);
+        }

This makes me a bit uncomfortable - if the window can be destroyed, it is quite likely that we are looking at a dangling pointer here and access freed memory. Do we need to use a weak ref ?

There's also some formatting issues here (space before (, and redundant {} )
Comment 4 Michael Gratton 2017-02-17 01:32:58 UTC
Created attachment 346034 [details] [review]
Use weak ref to clear scrolled window

Thanks for the review.

Updated patch uses a weak ref that clears the window and also the cursor, and further now ensures that also happens on destroy, so we don't leak the cursor if it hasn't been uninstalled.
Comment 5 GNOME Infrastructure Team 2018-05-02 18:02:57 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/749.