jhass / crystal-gobject

gobject-introspection for Crystal
BSD 3-Clause "New" or "Revised" License
127 stars 13 forks source link

Unexpected null pointer returned from gtk_entry_get_text #85

Open trans opened 3 years ago

trans commented 3 years ago

Getting critical error:

(benchgui:95622): GLib-GObject-CRITICAL **: 08:46:44.520: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

(benchgui:95622): Gtk-CRITICAL **: 08:46:44.520: gtk_entry_set_text: assertion 'GTK_IS_ENTRY (entry)' failed

(benchgui:95622): Gtk-CRITICAL **: 08:46:44.520: gtk_entry_set_text: assertion 'GTK_IS_ENTRY (entry)' failed

(benchgui:95622): Gtk-CRITICAL **: 08:46:44.520: gtk_entry_get_text: assertion 'GTK_IS_ENTRY (entry)' failed
Unhandled exception in spawn: An unexpected null pointer was returned from gtk_entry_get_text.

This means that there is a missing may return null annotation in the GIR
file defining this function. Please report this as a bug upstream.

For now please manually override the generated wrapper method with one that
handles the null pointer. You may also want to upstream this override to the
shard maintaining manual overrides for the respective library. (Exception)
  from lib/gobject/src/gobject.cr:12:5 in 'raise_unexpected_null'
  from lib/gobject/src/gtk/gtk.cr:4:1 in 'text'
  from src/gtk/mainui.cr:130:62 in '->'
  from ../../../../../../usr/share/crystal/src/primitives.cr:255:3 in 'update'
  from src/gtk/mainui.cr:389:9 in 'update'
  from src/benchgui.cr:90:7 in 'handle_message'
  from src/benchgui.cr:73:11 in 'listen'
  from src/benchgui.cr:47:7 in '->'
  from ../../../../../../usr/share/crystal/src/primitives.cr:255:3 in 'run'
  from ../../../../../../usr/share/crystal/src/fiber.cr:92:34 in '->'
  from ???

My source code at src/gtk/mainui.cr:130:62 in '->' is simply calling Gtk::Entry#text.

jhass commented 3 years ago

This is a little weird, looking at usages of gtk_entry_get_text it doesn't seem to be frequently null-checked, so I wonder if it's nullable or not now.

Maybe you're hitting the problem described at https://github.com/jhass/crystal-malloc_pthread_shim :/

Could try to find a minimal example that reproduces this?