0

I'm writing a text editor in python and gtk3 and I keep getting vague warnings from somewhere within glib when I close a window:

/usr/lib/python2.7/dist-packages/gi/types.py:47: Warning: invalid (NULL) pointer instance
  return info.invoke(*args, **kwargs)

How can I debug this? I tried running it in gdb, hoping I might be able to learn something from a breakpoint at g_logv, but the warnings appear without triggering the breakpoint. I can't easily replace the log handler either because of https://bugzilla.gnome.org/show_bug.cgi?id=670507.

I've even tried altering the python file referenced in the message so that it always prints a python backtrace at that point, but it has to do it whether the error occurs or not and it gets called on every gobject method call, so it's difficult to interpret the results, and it still doesn't tell me anything about which pointer is null.

ptomato
  • 56,175
  • 13
  • 112
  • 165
realh
  • 962
  • 2
  • 7
  • 22
  • Write some tests for individual classes of your project. Might help you isolate the culprit. – XORcist Dec 02 '12 at 22:35
  • Are you sure you set the breakpoint at the right function (`g_log` or `g_logv`?) Breaking on `g_log` in a Python program works fine for me. – ptomato Dec 03 '12 at 16:42
  • This is one of those tricky things where testing individual classes is ineffective. It was working OK until I tried to embed my widget in a GtkNotebook. And if I try rewriting what appears to be causing it, the warning just crops up somewhere else. – realh Dec 03 '12 at 17:09
  • I set breakpoints on g_log and g_logv (I checked the source and g_log calls g_logv anyway). – realh Dec 03 '12 at 17:12

1 Answers1

1

If you want to use gdb, just run your script with the G_DEBUG environment variable set to "fatal-warnings" (G_DEBUG=fatal-warnings ./your-script.py). There is documentation in the Running GLib Applications section of the GLib manual.

nemequ
  • 16,623
  • 1
  • 43
  • 62
  • I should have thought of that! But, having tried it, it just exits silently, even in gdb :-(. I was about to try setting a breakpoint on abort when I accidentally triggered something in my python which is supposed to detect a repeat attempt to destroy the same object, so hopefully I can get somewhere now! – realh Dec 03 '12 at 17:39
  • Then the warnings are not coming from within GLib, as you stated in your question. That also explains why breaking on g_logv doesn't work, either. – nemequ Dec 04 '12 at 20:54