gtk, 2.8.9/10, wx.App() hangs

hi.
i am having something like a misconfiguration problem, but have no
idea which way to fix it. Stripped down to one line,
python -c "import wx; wx.App()" hangs.
it's ubuntu karmic. It was the default 2.8.9 (coming from
ubuntu-jaunty), then i tried upgrading from wxwidgets.org repository
to 2.8.10.1 - all the same.
The ansi flavour works though, so i guess its something
gtk-unicode-related (or missing, deleted, misconfigured, whatever).

here the traceback of "gdb python", running above line, then ctrl-c:

~$ gdb python
GNU gdb (GDB) 6.8.50.20090628-cvs-debian
"i486-linux-gnu".
(no debugging symbols found)
(gdb) r
Starting program: /usr/bin/python
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
(no debugging symbols found)
Python 2.6.2+ (release26-maint, Jun 19 2009, 15:14:35)
[GCC 4.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(no debugging symbols found)
>>> import wx
(no debugging symbols found)...
>>> wx.App()

(process:9750): GLib-GObject-CRITICAL **:
/build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-CRITICAL **: g_once_init_leave: assertion
`initialization_value != 0' failed

(process:9750): Gdk-CRITICAL **: gdk_cursor_new_for_display: assertion
`GDK_IS_DISPLAY (display)' failed

(process:9750): GLib-GObject-CRITICAL **:
/build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-CRITICAL **: g_once_init_leave: assertion
`initialization_value != 0' failed

(process:9750): GLib-GObject-CRITICAL **:
/build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-GObject-CRITICAL **:
/build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-GObject-CRITICAL **:
/build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-GObject-CRITICAL **: g_type_add_interface_static:
assertion `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed

(process:9750): GLib-GObject-CRITICAL **:
/build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-GObject-CRITICAL **: g_type_add_interface_static:
assertion `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed

(process:9750): GLib-GObject-CRITICAL **:
/build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-GObject-CRITICAL **:
/build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-GObject-CRITICAL **: g_type_add_interface_static:
assertion `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed

(process:9750): GLib-GObject-CRITICAL **:
/build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-CRITICAL **: g_once_init_leave: assertion
`initialization_value != 0' failed

(process:9750): GLib-GObject-CRITICAL **:
/build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-GObject-CRITICAL **:
/build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-GObject-CRITICAL **: g_type_add_interface_static:
assertion `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed

(process:9750): GLib-CRITICAL **: g_once_init_leave: assertion
`initialization_value != 0' failed

(process:9750): GLib-GObject-CRITICAL **:
/build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-GObject-CRITICAL **:
/build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-GObject-CRITICAL **: g_type_add_interface_static:
assertion `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed

(process:9750): GLib-CRITICAL **: g_once_init_leave: assertion
`initialization_value != 0' failed

(process:9750): GLib-GObject-CRITICAL **:
/build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization
assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-CRITICAL **: g_once_init_leave: assertion
`initialization_value != 0' failed

(process:9750): GLib-GObject-CRITICAL **: g_object_new: assertion
`G_TYPE_IS_OBJECT (object_type)' failed

******* here the thing hangs ******
^C
Program received signal SIGINT, Interrupt.
0x0542b0cb in g_slist_find () from /usr/lib/libglib-2.0.so.0
(gdb) bt
#0 0x0542b0cb in g_slist_find () from /usr/lib/libglib-2.0.so.0
#1 0x054365fa in g_once_init_enter_impl () from /usr/lib/libglib-2.0.so.0
#2 0x012ba166 in gtk_dialog_get_type () from /usr/lib/libgtk-x11-2.0.so.0
#3 0x0136ccac in gtk_message_dialog_new () from
/usr/lib/libgtk-x11-2.0.so.0
#4 0x01054a1d in wxMessageDialog::wxMessageDialog(wxWindow*, wxString
const&, wxString const&, long, wxPoint const&) () from
/usr/lib/libwx_gtk2u_core-2.8.so.0
#5 0x00fb6caf in wxMessageBox(wxString const&, wxString const&, long,
wxWindow*, int, int) ()
    from /usr/lib/libwx_gtk2u_core-2.8.so.0
#6 0x0112138c in wxLogGui::Flush() () from
/usr/lib/libwx_gtk2u_core-2.8.so.0
#7 0x00d850ca in wxLog::SetActiveTarget(wxLog*) () from
/usr/lib/libwx_baseu-2.8.so.0
#8 0x00d77eb9 in wxEntryStart(int&, wchar_t**) () from
/usr/lib/libwx_baseu-2.8.so.0
#9 0x00d783c7 in wxEntryStart(int&, char**) () from
/usr/lib/libwx_baseu-2.8.so.0
#10 0x0045300c in wxPyApp::_BootstrapApp() ()
    from /usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/_core_.so
#11 0x004d3c91 in ?? () from
/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/_core_.so
#12 0x080dc3cb in PyEval_EvalFrameEx ()
#13 0x080ddcc2 in PyEval_EvalCodeEx ()
#14 0x080dc1e5 in PyEval_EvalFrameEx ()
#15 0x080ddcc2 in PyEval_EvalCodeEx ()
#16 0x0816015c in ?? ()
#17 0x080611aa in PyObject_Call ()
#18 0x0806857c in ?? ()
#19 0x080611aa in PyObject_Call ()
#20 0x080aec4e in ?? ()
#21 0x080aa325 in ?? ()
#22 0x080611aa in PyObject_Call ()
#23 0x080db450 in PyEval_EvalFrameEx ()
#24 0x080ddcc2 in PyEval_EvalCodeEx ()
#25 0x080dddc7 in PyEval_EvalCode ()
#26 0x080fa6bf in PyRun_InteractiveOneFlags ()
#27 0x080fa8b8 in PyRun_InteractiveLoopFlags ()
#28 0x080fb013 in PyRun_AnyFileExFlags ()
#29 0x0805c878 in Py_Main ()
#30 0x0805ba8b in main ()
(gdb)

what i'm getting from this is that the thing tries to tell me
something in the very begining (wxmessage from wxlog) but seems
there's no gui to attach to yet?
any way to put that log into elsewhere?
i've tried reinstalling gtk stuff, wx stuff, all the same.
any idea? are those gtk-criticals on to somethig or not really?
i havent tried only rebuilding yet...

ciao
svil

svilen dobrev wrote:

hi.
i am having something like a misconfiguration problem, but have no idea which way to fix it. Stripped down to one line,
python -c "import wx; wx.App()" hangs.
it's ubuntu karmic. It was the default 2.8.9 (coming from ubuntu-jaunty), then i tried upgrading from wxwidgets.org repository to 2.8.10.1 - all the same.
The ansi flavour works though, so i guess its something gtk-unicode-related (or missing, deleted, misconfigured, whatever).

here the traceback of "gdb python", running above line, then ctrl-c:

what i'm getting from this is that the thing tries to tell me something in the very begining (wxmessage from wxlog) but seems there's no gui to attach to yet?
any way to put that log into elsewhere?

IIRC wxLog starts out going to stderr and won't try using the message dlg until after the toolkit has been initialized, so that probably isn't the problem. With all the glib/gtk messages I suspect that there is a problem with using the newer GTK lib, so at a minimum you probably need to rebuild wx... But first try installing the -dbg version of the Python and wx packages and try again using them to see if you can get some more details from the backtrace or an assert.

···

--
Robin Dunn
Software Craftsman

the dbg version gives same hang/stacktrace, and i went to see what the wxMessage is trying to tell: it's an error saying
(gdb) print message
..."Cannot convert from the charset 'Unknown encoding (-1)'!"

that message is only in wxCSConv::DoCreate() in common/strconv.cpp.
And this complaining happens in ConvertArgsToUnicode() in wxEntryStart(), while trying to convert "/usr/bin/python-dbg";
m_name is 0, m_encoding is wxFONTENCODING_SYSTEM, which is -1.
That same error happens when running, say, plain c++ wxwidgets/samples/typetest.cpp, although nothing hangs there.

if i set LANG=C, it goes away and all is fine - no gtk messages, all works...

which means - the encodings system doesnot recognise my LANG=whatever. yeah, fine...

seems to me, the mechanism for switching from initial temporary wxLog to wxLogGui is not working ok. e.g. why the Flush() is being called over wxLogGui? the temporary is also a wxLogGui or what?

ahha, see what i found after more debuging:
when the message happens - in the DoCommonPreInit(), in the "first" wxLog::SetActivetarget( wxLogBuffer), there's still no wxLog-ActiveTarget whatsoever (ok), AND one is being created and set up by GetActiveTarget() just there, AND seems there is already a non-null wxApp pointer, so it becomes not a wxLogStdError, but a wxLogGui. Which is later being Flushed etc - probably too soon.
so instead of wxLogBuffer -> wxLogGui ..., it happens like
wxLogGui -> wxLogBuffer -> wxLogGui ...
it's an "error inside the error logging" kind of pattern.
is this a bug for a ticket or?

ciao
svilen

www.svilendobrev.com
www.svilendobrev.com/rabota/

svilen dobrev wrote:

···

hi.
i am having something like a misconfiguration problem, but have no idea which way to fix it. Stripped down to one line,
python -c "import wx; wx.App()" hangs.
it's ubuntu karmic. It was the default 2.8.9 (coming from ubuntu-jaunty), then i tried upgrading from wxwidgets.org repository to 2.8.10.1 - all the same.
The ansi flavour works though, so i guess its something gtk-unicode-related (or missing, deleted, misconfigured, whatever).

here the traceback of "gdb python", running above line, then ctrl-c:

~$ gdb python
GNU gdb (GDB) 6.8.50.20090628-cvs-debian
"i486-linux-gnu".
(no debugging symbols found)
(gdb) r
Starting program: /usr/bin/python
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
(no debugging symbols found)
Python 2.6.2+ (release26-maint, Jun 19 2009, 15:14:35)
[GCC 4.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(no debugging symbols found)
>>> import wx
(no debugging symbols found)...
>>> wx.App()

(process:9750): GLib-GObject-CRITICAL **: /build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-CRITICAL **: g_once_init_leave: assertion `initialization_value != 0' failed

(process:9750): Gdk-CRITICAL **: gdk_cursor_new_for_display: assertion `GDK_IS_DISPLAY (display)' failed

(process:9750): GLib-GObject-CRITICAL **: /build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-CRITICAL **: g_once_init_leave: assertion `initialization_value != 0' failed

(process:9750): GLib-GObject-CRITICAL **: /build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-GObject-CRITICAL **: /build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-GObject-CRITICAL **: /build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-GObject-CRITICAL **: g_type_add_interface_static: assertion `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed

(process:9750): GLib-GObject-CRITICAL **: /build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-GObject-CRITICAL **: g_type_add_interface_static: assertion `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed

(process:9750): GLib-GObject-CRITICAL **: /build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-GObject-CRITICAL **: /build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-GObject-CRITICAL **: g_type_add_interface_static: assertion `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed

(process:9750): GLib-GObject-CRITICAL **: /build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-CRITICAL **: g_once_init_leave: assertion `initialization_value != 0' failed

(process:9750): GLib-GObject-CRITICAL **: /build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-GObject-CRITICAL **: /build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-GObject-CRITICAL **: g_type_add_interface_static: assertion `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed

(process:9750): GLib-CRITICAL **: g_once_init_leave: assertion `initialization_value != 0' failed

(process:9750): GLib-GObject-CRITICAL **: /build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-GObject-CRITICAL **: /build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-GObject-CRITICAL **: g_type_add_interface_static: assertion `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed

(process:9750): GLib-CRITICAL **: g_once_init_leave: assertion `initialization_value != 0' failed

(process:9750): GLib-GObject-CRITICAL **: /build/buildd/glib2.0-2.21.3/gobject/gtype.c:2458: initialization assertion failed, use IA__g_type_init() prior to this function

(process:9750): GLib-CRITICAL **: g_once_init_leave: assertion `initialization_value != 0' failed

(process:9750): GLib-GObject-CRITICAL **: g_object_new: assertion `G_TYPE_IS_OBJECT (object_type)' failed

******* here the thing hangs ******
^C
Program received signal SIGINT, Interrupt.
0x0542b0cb in g_slist_find () from /usr/lib/libglib-2.0.so.0
(gdb) bt
#0 0x0542b0cb in g_slist_find () from /usr/lib/libglib-2.0.so.0
#1 0x054365fa in g_once_init_enter_impl () from /usr/lib/libglib-2.0.so.0
#2 0x012ba166 in gtk_dialog_get_type () from /usr/lib/libgtk-x11-2.0.so.0
#3 0x0136ccac in gtk_message_dialog_new () from /usr/lib/libgtk-x11-2.0.so.0
#4 0x01054a1d in wxMessageDialog::wxMessageDialog(wxWindow*, wxString const&, wxString const&, long, wxPoint const&) () from /usr/lib/libwx_gtk2u_core-2.8.so.0
#5 0x00fb6caf in wxMessageBox(wxString const&, wxString const&, long, wxWindow*, int, int) ()
   from /usr/lib/libwx_gtk2u_core-2.8.so.0
#6 0x0112138c in wxLogGui::Flush() () from /usr/lib/libwx_gtk2u_core-2.8.so.0
#7 0x00d850ca in wxLog::SetActiveTarget(wxLog*) () from /usr/lib/libwx_baseu-2.8.so.0
#8 0x00d77eb9 in wxEntryStart(int&, wchar_t**) () from /usr/lib/libwx_baseu-2.8.so.0
#9 0x00d783c7 in wxEntryStart(int&, char**) () from /usr/lib/libwx_baseu-2.8.so.0
#10 0x0045300c in wxPyApp::_BootstrapApp() ()
   from /usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/_core_.so
#11 0x004d3c91 in ?? () from /usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/_core_.so
#12 0x080dc3cb in PyEval_EvalFrameEx ()
#13 0x080ddcc2 in PyEval_EvalCodeEx ()
#14 0x080dc1e5 in PyEval_EvalFrameEx ()
#15 0x080ddcc2 in PyEval_EvalCodeEx ()
#16 0x0816015c in ?? ()
#17 0x080611aa in PyObject_Call ()
#18 0x0806857c in ?? ()
#19 0x080611aa in PyObject_Call ()
#20 0x080aec4e in ?? ()
#21 0x080aa325 in ?? ()
#22 0x080611aa in PyObject_Call ()
#23 0x080db450 in PyEval_EvalFrameEx ()
#24 0x080ddcc2 in PyEval_EvalCodeEx ()
#25 0x080dddc7 in PyEval_EvalCode ()
#26 0x080fa6bf in PyRun_InteractiveOneFlags ()
#27 0x080fa8b8 in PyRun_InteractiveLoopFlags ()
#28 0x080fb013 in PyRun_AnyFileExFlags ()
#29 0x0805c878 in Py_Main ()
#30 0x0805ba8b in main ()
(gdb)

what i'm getting from this is that the thing tries to tell me something in the very begining (wxmessage from wxlog) but seems there's no gui to attach to yet?
any way to put that log into elsewhere?
i've tried reinstalling gtk stuff, wx stuff, all the same.
any idea? are those gtk-criticals on to somethig or not really?
i havent tried only rebuilding yet...

ciao
svil

svilen dobrev wrote:

the dbg version gives same hang/stacktrace, and i went to see what the wxMessage is trying to tell: it's an error saying
(gdb) print message
..."Cannot convert from the charset 'Unknown encoding (-1)'!"

that message is only in wxCSConv::DoCreate() in common/strconv.cpp.
And this complaining happens in ConvertArgsToUnicode() in wxEntryStart(), while trying to convert "/usr/bin/python-dbg";
m_name is 0, m_encoding is wxFONTENCODING_SYSTEM, which is -1.
That same error happens when running, say, plain c++ wxwidgets/samples/typetest.cpp, although nothing hangs there.

if i set LANG=C, it goes away and all is fine - no gtk messages, all works...

which means - the encodings system doesnot recognise my LANG=whatever. yeah, fine...

seems to me, the mechanism for switching from initial temporary wxLog to wxLogGui is not working ok. e.g. why the Flush() is being called over wxLogGui? the temporary is also a wxLogGui or what?

ahha, see what i found after more debuging:
when the message happens - in the DoCommonPreInit(), in the "first" wxLog::SetActivetarget( wxLogBuffer), there's still no wxLog-ActiveTarget whatsoever (ok), AND one is being created and set up by GetActiveTarget() just there, AND seems there is already a non-null wxApp pointer, so it becomes not a wxLogStdError, but a wxLogGui. Which is later being Flushed etc - probably too soon.
so instead of wxLogBuffer -> wxLogGui ..., it happens like
wxLogGui -> wxLogBuffer -> wxLogGui ...
it's an "error inside the error logging" kind of pattern.
is this a bug for a ticket or?

Yes.

···

--
Robin Dunn
Software Craftsman