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 785255 - Quitting world's simplest program containing a single GtkEntry causes a Pango-CRITICAL **: pango_layout_get_cursor_pos: assertion 'index >= 0 && index <= layout->length' failed
Quitting world's simplest program containing a single GtkEntry causes a Pango...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkEntry
3.22.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2017-07-22 00:32 UTC by Daniel Boles
Modified: 2017-07-31 19:07 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
entry: Do not recompute if we do not have a screen (866 bytes, patch)
2017-07-22 00:53 UTC, Daniel Boles
none Details | Review

Description Daniel Boles 2017-07-22 00:32:09 UTC
#include <gtk/gtk.h>

int
main (int argc, char **argv)
{
  gtk_init (&argc, &argv);

  GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  GtkWidget *entry = gtk_entry_new ();
  gtk_container_add ((GtkContainer *)window, entry);
  gtk_widget_show_all (window);

  gtk_main ();
}


* Run it (both GTK+ from Debian and my jhbuild do this)
* Type some text (length/content doesn't matter)
* Close the window (method doesn't matter)


(a.out:9309): Pango-CRITICAL **: pango_layout_get_cursor_pos: assertion 'index >= 0 && index <= layout->length' failed

Thread 1 "a.out" received signal SIGTRAP, Trace/breakpoint trap.
_g_log_abort (breakpoint=1) at /home/daniel/jhbuild/checkout/gnome/glib/glib/gmessages.c:549
549	}
(ins)(gdb) bt
  • #0 _g_log_abort
    at /home/daniel/jhbuild/checkout/gnome/glib/glib/gmessages.c line 549
  • #1 g_logv
    at /home/daniel/jhbuild/checkout/gnome/glib/glib/gmessages.c line 1357
  • #2 g_log
    at /home/daniel/jhbuild/checkout/gnome/glib/glib/gmessages.c line 1398
  • #3 g_return_if_fail_warning
    at /home/daniel/jhbuild/checkout/gnome/glib/glib/gmessages.c line 2687
  • #4 pango_layout_get_cursor_pos
    at ../../../../jhbuild/checkout/gnome/pango/pango/pango-layout.c line 2369
  • #5 gtk_entry_get_cursor_locations
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gtk/gtkentry.c line 6822
  • #6 update_im_cursor_location
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gtk/gtkentry.c line 6163
  • #7 gtk_entry_recompute
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gtk/gtkentry.c line 6194
  • #8 gtk_entry_screen_changed
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gtk/gtkentry.c line 5065
  • #9 g_cclosure_marshal_VOID__OBJECTv
    at /home/daniel/jhbuild/checkout/gnome/glib/gobject/gmarshal.c line 2102
  • #10 g_type_class_meta_marshalv
    at /home/daniel/jhbuild/checkout/gnome/glib/gobject/gclosure.c line 1024
  • #11 _g_closure_invoke_va
    at /home/daniel/jhbuild/checkout/gnome/glib/gobject/gclosure.c line 867
  • #12 g_signal_emit_valist
    at /home/daniel/jhbuild/checkout/gnome/glib/gobject/gsignal.c line 3300
  • #13 g_signal_emit
    at /home/daniel/jhbuild/checkout/gnome/glib/gobject/gsignal.c line 3447
  • #14 do_screen_change
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gtk/gtkwidget.c line 9880
  • #15 gtk_widget_propagate_hierarchy_changed_recurse
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gtk/gtkwidget.c line 9911
  • #16 _gtk_widget_propagate_hierarchy_changed
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gtk/gtkwidget.c line 9952
  • #17 gtk_widget_unparent
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gtk/gtkwidget.c line 4659
  • #18 gtk_bin_remove
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gtk/gtkbin.c line 151
  • #19 gtk_window_remove
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gtk/gtkwindow.c line 8313
  • #20 g_cclosure_marshal_VOID__OBJECTv
    at /home/daniel/jhbuild/checkout/gnome/glib/gobject/gmarshal.c line 2102
  • #21 g_type_class_meta_marshalv
    at /home/daniel/jhbuild/checkout/gnome/glib/gobject/gclosure.c line 1024
  • #22 _g_closure_invoke_va
    at /home/daniel/jhbuild/checkout/gnome/glib/gobject/gclosure.c line 867
  • #23 g_signal_emit_valist
    at /home/daniel/jhbuild/checkout/gnome/glib/gobject/gsignal.c line 3300
  • #24 g_signal_emit
    at /home/daniel/jhbuild/checkout/gnome/glib/gobject/gsignal.c line 3447
  • #25 gtk_container_remove
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gtk/gtkcontainer.c line 1905
  • #26 gtk_widget_dispose
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gtk/gtkwidget.c line 12058
  • #27 gtk_entry_dispose
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gtk/gtkentry.c line 2930
  • #28 g_object_run_dispose
    at /home/daniel/jhbuild/checkout/gnome/glib/gobject/gobject.c line 1084
  • #29 gtk_widget_destroy
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gtk/gtkwidget.c line 4722
  • #30 gtk_window_forall
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gtk/gtkwindow.c line 8352
  • #31 gtk_container_foreach
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gtk/gtkcontainer.c line 2472
  • #32 gtk_container_destroy
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gtk/gtkcontainer.c line 1700
  • #33 gtk_window_destroy
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gtk/gtkwindow.c line 5929
  • #34 g_cclosure_marshal_VOID__VOID
    at /home/daniel/jhbuild/checkout/gnome/glib/gobject/gmarshal.c line 875
  • #35 g_type_class_meta_marshal
    at /home/daniel/jhbuild/checkout/gnome/glib/gobject/gclosure.c line 997
  • #36 g_closure_invoke
    at /home/daniel/jhbuild/checkout/gnome/glib/gobject/gclosure.c line 804
  • #37 signal_emit_unlocked_R
    at /home/daniel/jhbuild/checkout/gnome/glib/gobject/gsignal.c line 3751
  • #38 g_signal_emit_valist
    at /home/daniel/jhbuild/checkout/gnome/glib/gobject/gsignal.c line 3391
  • #39 g_signal_emit
    at /home/daniel/jhbuild/checkout/gnome/glib/gobject/gsignal.c line 3447
  • #40 gtk_widget_dispose
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gtk/gtkwidget.c line 12069
  • #41 gtk_window_dispose
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gtk/gtkwindow.c line 3151
  • #42 g_object_run_dispose
    at /home/daniel/jhbuild/checkout/gnome/glib/gobject/gobject.c line 1084
  • #43 gtk_widget_destroy
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gtk/gtkwidget.c line 4722
  • #44 gtk_main_do_event
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gtk/gtkmain.c line 1804
  • #45 _gdk_event_emit
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gdk/gdkevents.c line 73
  • #46 gdk_event_source_dispatch
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gdk/x11/gdkeventsource.c line 367
  • #47 g_main_dispatch
    at /home/daniel/jhbuild/checkout/gnome/glib/glib/gmain.c line 3234
  • #48 g_main_context_dispatch
    at /home/daniel/jhbuild/checkout/gnome/glib/glib/gmain.c line 3899
  • #49 g_main_context_iterate
    at /home/daniel/jhbuild/checkout/gnome/glib/glib/gmain.c line 3972
  • #50 g_main_loop_run
    at /home/daniel/jhbuild/checkout/gnome/glib/glib/gmain.c line 4168
  • #51 gtk_main
    at /home/daniel/jhbuild/checkout/gnome/gtk+-3/gtk/gtkmain.c line 1312
  • #52 main

Comment 1 Daniel Boles 2017-07-22 00:53:13 UTC
Created attachment 356153 [details] [review]
entry: Do not recompute if we do not have a screen

This was causing Pango-CRITICALs during destruction and unparenting. The
fix is to do what e.g. GtkButton does: do not handle :screen-changed if
we've changed to not having a screen.
Comment 2 Daniel Boles 2017-07-31 19:01:09 UTC
Alternatively, if there's any reason to keep running recompute() on change to no screen, we could pick 9047a5dc52fa31dec2dc8adcb73128ed82333385 to gtk-3-22, as my testing shows that this commit is why the same critical does not occur in master.

This seems less intrusive, so it's a winner IMO.
Comment 3 Daniel Boles 2017-07-31 19:07:16 UTC
^ done