Segmentation fault in gobject caused by wxPython?

Hi,

I have a wxPython application and occasionally users send me bugreports
with gdb backtraces like below (I have not bee able to reproduce any of
them).
My question is, as I have no idea what causes this, if there's anything
I can do prevent it? (it seems to me the segfault somehow happens
because of a wx call out to gtk/glib/gobject, none of which I use
directly in my app)

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7adac45 in do_warn () from /usr/lib/libpython2.7.so.1.0

(gdb) bt
#0 0x00007ffff7adac45 in do_warn () from /usr/lib/libpython2.7.so.1.0
#1 0x00007ffff7adb39d in PyErr_WarnEx () from /usr/lib/libpython2.7.so.1.0
#2 0x00007fffe45b7f15 in ?? () from
/usr/lib/python2.7/site-packages/gi/_gobject/_gobject.so
#3 0x00007ffff0e4ec29 in g_logv () from /usr/lib/libglib-2.0.so.0
#4 0x00007ffff0e4ee32 in g_log () from /usr/lib/libglib-2.0.so.0
#5 0x00007ffff1114daf in g_object_class_install_property () from
/usr/lib/libgobject-2.0.so.0
#6 0x00007ffff19b64ab in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#7 0x00007ffff18ae725 in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#8 0x00007ffff112d00e in g_type_class_ref () from
/usr/lib/libgobject-2.0.so.0
#9 0x00007ffff1115d72 in g_object_newv () from /usr/lib/libgobject-2.0.so.0
#10 0x00007ffff11164bc in g_object_new () from /usr/lib/libgobject-2.0.so.0
#11 0x00007ffff2af44cd in wxSystemSettingsNative::GetFont(wxSystemFont)
() from /usr/lib/libwx_gtk2u_core-2.8.so.0
#12 0x00007ffff2b8cd82 in wxStockGDI::GetFont(wxStockGDI::Item) () from
/usr/lib/libwx_gtk2u_core-2.8.so.0
#13 0x00007ffff2b8cca9 in wxStockGDI::GetFont(wxStockGDI::Item) () from
/usr/lib/libwx_gtk2u_core-2.8.so.0
#14 0x00007fffe661fd92 in ?? () from
/usr/lib/python2.7/site-packages/wx-2.8-gtk2-unicode/wx/_gdi_.so
#15 0x00007ffff7af9e94 in PyEval_EvalFrameEx () from
/usr/lib/libpython2.7.so.1.0
#16 0x00007ffff7afa800 in PyEval_EvalCodeEx () from
/usr/lib/libpython2.7.so.1.0
#17 0x00007ffff7af8d0e in PyEval_EvalFrameEx () from
/usr/lib/libpython2.7.so.1.0
#18 0x00007ffff7af8db2 in PyEval_EvalFrameEx () from
/usr/lib/libpython2.7.so.1.0
#19 0x00007ffff7afa800 in PyEval_EvalCodeEx () from
/usr/lib/libpython2.7.so.1.0
#20 0x00007ffff7a8a5d0 in function_call () from /usr/lib/libpython2.7.so.1.0
#21 0x00007ffff7a66913 in PyObject_Call () from /usr/lib/libpython2.7.so.1.0
#22 0x00007ffff7a750fd in instancemethod_call () from
/usr/lib/libpython2.7.so.1.0
#23 0x00007ffff7a66913 in PyObject_Call () from /usr/lib/libpython2.7.so.1.0
#24 0x00007ffff7af46a7 in PyEval_CallObjectWithKeywords () from
/usr/lib/libpython2.7.so.1.0
#25 0x00007ffff321cece in wxPyApp::_BootstrapApp() () from
/usr/lib/python2.7/site-packages/wx-2.8-gtk2-unicode/wx/_core_.so
#26 0x00007ffff325466d in ?? () from
/usr/lib/python2.7/site-packages/wx-2.8-gtk2-unicode/wx/_core_.so
#27 0x00007ffff7af9e94 in PyEval_EvalFrameEx () from
/usr/lib/libpython2.7.so.1.0
#28 0x00007ffff7afa800 in PyEval_EvalCodeEx () from
/usr/lib/libpython2.7.so.1.0
#29 0x00007ffff7af8d0e in PyEval_EvalFrameEx () from
/usr/lib/libpython2.7.so.1.0
#30 0x00007ffff7afa800 in PyEval_EvalCodeEx () from
/usr/lib/libpython2.7.so.1.0
#31 0x00007ffff7a8a6ad in function_call () from /usr/lib/libpython2.7.so.1.0
#32 0x00007ffff7a66913 in PyObject_Call () from /usr/lib/libpython2.7.so.1.0
#33 0x00007ffff7a750fd in instancemethod_call () from
/usr/lib/libpython2.7.so.1.0
#34 0x00007ffff7a66913 in PyObject_Call () from /usr/lib/libpython2.7.so.1.0
#35 0x00007ffff7aba7e7 in slot_tp_init () from /usr/lib/libpython2.7.so.1.0
#36 0x00007ffff7ab955f in type_call () from /usr/lib/libpython2.7.so.1.0
#37 0x00007ffff7a66913 in PyObject_Call () from /usr/lib/libpython2.7.so.1.0
#38 0x00007ffff7af7203 in PyEval_EvalFrameEx () from
/usr/lib/libpython2.7.so.1.0
#39 0x00007ffff7afa800 in PyEval_EvalCodeEx () from
/usr/lib/libpython2.7.so.1.0
#40 0x00007ffff7af8d0e in PyEval_EvalFrameEx () from
/usr/lib/libpython2.7.so.1.0
#41 0x00007ffff7afa800 in PyEval_EvalCodeEx () from
/usr/lib/libpython2.7.so.1.0
#42 0x00007ffff7af8d0e in PyEval_EvalFrameEx () from
/usr/lib/libpython2.7.so.1.0
#43 0x00007ffff7afa800 in PyEval_EvalCodeEx () from
/usr/lib/libpython2.7.so.1.0
#44 0x00007ffff7afa902 in PyEval_EvalCode () from
/usr/lib/libpython2.7.so.1.0
#45 0x00007ffff7b133ff in run_mod () from /usr/lib/libpython2.7.so.1.0
#46 0x00007ffff7b144de in PyRun_FileExFlags () from
/usr/lib/libpython2.7.so.1.0
#47 0x00007ffff7b15649 in PyRun_SimpleFileExFlags () from
/usr/lib/libpython2.7.so.1.0
#48 0x00007ffff7b25dfd in Py_Main () from /usr/lib/libpython2.7.so.1.0
#49 0x00007ffff7475bc5 in __libc_start_main () from /lib/libc.so.6
#50 0x0000000000400711 in _start ()

···

--
Florian Höch

Florian Höch wrote:

Hi,

I have a wxPython application and occasionally users send me bugreports
with gdb backtraces like below (I have not bee able to reproduce any of
them).
My question is, as I have no idea what causes this, if there's anything
I can do prevent it? (it seems to me the segfault somehow happens
because of a wx call out to gtk/glib/gobject, none of which I use
directly in my app)

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7adac45 in do_warn () from /usr/lib/libpython2.7.so.1.0

(gdb) bt
#0 0x00007ffff7adac45 in do_warn () from /usr/lib/libpython2.7.so.1.0
#1 0x00007ffff7adb39d in PyErr_WarnEx () from /usr/lib/libpython2.7.so.1.0
#2 0x00007fffe45b7f15 in ?? () from
/usr/lib/python2.7/site-packages/gi/_gobject/_gobject.so
#3 0x00007ffff0e4ec29 in g_logv () from /usr/lib/libglib-2.0.so.0
#4 0x00007ffff0e4ee32 in g_log () from /usr/lib/libglib-2.0.so.0
#5 0x00007ffff1114daf in g_object_class_install_property () from
/usr/lib/libgobject-2.0.so.0
#6 0x00007ffff19b64ab in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#7 0x00007ffff18ae725 in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#8 0x00007ffff112d00e in g_type_class_ref () from
/usr/lib/libgobject-2.0.so.0
#9 0x00007ffff1115d72 in g_object_newv () from /usr/lib/libgobject-2.0.so.0
#10 0x00007ffff11164bc in g_object_new () from /usr/lib/libgobject-2.0.so.0
#11 0x00007ffff2af44cd in wxSystemSettingsNative::GetFont(wxSystemFont)
() from /usr/lib/libwx_gtk2u_core-2.8.so.0

Does your application import any 3rd-party libraries that may in turn be importing gtk wrappers? There really shouldn't be any way that a call to wxSystemSettingsNative::GetFont should result in a call to something in the gobject extension module, unless it has been set as a callback or event handler or dbus handler or similar. For that to happen I would assume that gtk, gdk or gobject has been imported earlier and has set up the callback.

···

--
Robin Dunn
Software Craftsman

Hi,

thanks for the hint. I actually have a module that imports Gio from
gi.repository, so I'm assuming that could be it. I've already asked the
user if he could try commenting out the import (it's not critical for
operation of the program, just a certain functionality will be affected).
Next I'll look if I can prevent the callback/handler somehow.

···

Am 15.03.2014 05:49, schrieb Robin Dunn:

Florian Höch wrote:

Hi,

I have a wxPython application and occasionally users send me bugreports
with gdb backtraces like below (I have not bee able to reproduce any of
them).
My question is, as I have no idea what causes this, if there's anything
I can do prevent it? (it seems to me the segfault somehow happens
because of a wx call out to gtk/glib/gobject, none of which I use
directly in my app)

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7adac45 in do_warn () from /usr/lib/libpython2.7.so.1.0

(gdb) bt
#0 0x00007ffff7adac45 in do_warn () from /usr/lib/libpython2.7.so.1.0
#1 0x00007ffff7adb39d in PyErr_WarnEx () from /usr/lib/libpython2.7.so.1.0
#2 0x00007fffe45b7f15 in ?? () from
/usr/lib/python2.7/site-packages/gi/_gobject/_gobject.so
#3 0x00007ffff0e4ec29 in g_logv () from /usr/lib/libglib-2.0.so.0
#4 0x00007ffff0e4ee32 in g_log () from /usr/lib/libglib-2.0.so.0
#5 0x00007ffff1114daf in g_object_class_install_property () from
/usr/lib/libgobject-2.0.so.0
#6 0x00007ffff19b64ab in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#7 0x00007ffff18ae725 in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#8 0x00007ffff112d00e in g_type_class_ref () from
/usr/lib/libgobject-2.0.so.0
#9 0x00007ffff1115d72 in g_object_newv () from /usr/lib/libgobject-2.0.so.0
#10 0x00007ffff11164bc in g_object_new () from /usr/lib/libgobject-2.0.so.0
#11 0x00007ffff2af44cd in wxSystemSettingsNative::GetFont(wxSystemFont)
() from /usr/lib/libwx_gtk2u_core-2.8.so.0

Does your application import any 3rd-party libraries that may in turn be
importing gtk wrappers? There really shouldn't be any way that a call
to wxSystemSettingsNative::GetFont should result in a call to something
in the gobject extension module, unless it has been set as a callback or
event handler or dbus handler or similar. For that to happen I would
assume that gtk, gdk or gobject has been imported earlier and has set up
the callback.

--
Florian Höch