Core dump on Linux with wxSplashScreen

I get a core dump on Linux if using wxSplashScreen and clicking on
it to close it early. My code is way too non-trivial to make a
trivial test case.

My code generates a splashscreen, a main window and a configuration
dialog. The config dialog is created in __init__ for the main
window. If configuration has not been done before, the slash
screen has Show(False) called and the config dialog is shown
modal (we are still in __init__ for the main window).

On Linux a core dump then results. Debug info below.
this is an invalid pointer in frames 0 and 1.
After the trace is a print of *this from frame 4.

(gdb) bt
#0 0x40792e96 in wxNodeBase::GetData() const (this=0x772f7365)
    at /space/rpm/BUILD/wxPythonSrc-2.4.2.4/include/wx/list.h:169
#1 0x40792e70 in wxNodeBase::Data() const (this=0x772f7365)
    at /space/rpm/BUILD/wxPythonSrc-2.4.2.4/include/wx/list.h:161
#2 0x4073496c in wxEvtHandler::SearchDynamicEventTable(wxEvent&) (this=0x8cca710, event=@0xbfffe980)
    at /space/rpm/BUILD/wxPythonSrc-2.4.2.4/src/common/event.cpp:1034
#3 0x407342d5 in wxEvtHandler::ProcessEvent(wxEvent&) (this=0x8cca710, event=@0xbfffe980)
    at /space/rpm/BUILD/wxPythonSrc-2.4.2.4/src/common/event.cpp:835
#4 0x407f6852 in wxWindowBase::Close(bool) (this=0x8cca710, force=true)
    at /space/rpm/BUILD/wxPythonSrc-2.4.2.4/src/common/wincmn.cpp:319
#5 0x40666519 in wxSplashScreenWindow::OnMouseEvent(wxMouseEvent&) (this=0x8ca2c20,
    event=@0xbfffeaf0) at /space/rpm/BUILD/wxPythonSrc-2.4.2.4/src/generic/splash.cpp:184
#6 0x40734606 in wxEvtHandler::SearchEventTable(wxEventTable&, wxEvent&) (this=0x8ca2c20,
    table=@0x40941568, event=@0xbfffeaf0)
    at /space/rpm/BUILD/wxPythonSrc-2.4.2.4/src/common/event.cpp:954
#7 0x4073438a in wxEvtHandler::ProcessEvent(wxEvent&) (this=0x8ca2c20, event=@0xbfffeaf0)
    at /space/rpm/BUILD/wxPythonSrc-2.4.2.4/src/common/event.cpp:870
#8 0x406e8e97 in gtk_window_button_press_callback (widget=0x8c89428, gdk_event=0x8c83bb0,
    win=0x8ca2c20) at /space/rpm/BUILD/wxPythonSrc-2.4.2.4/src/gtk/window.cpp:1609
#9 0x40b6ec26 in gtk_marshal_BOOL__POINTER () from /usr/lib/libgtk-1.2.so.0
#10 0x40ba7015 in gtk_signal_remove_emission_hook () from /usr/lib/libgtk-1.2.so.0
#11 0x40ba616d in gtk_signal_set_funcs () from /usr/lib/libgtk-1.2.so.0
#12 0x40ba3ab2 in gtk_signal_emit () from /usr/lib/libgtk-1.2.so.0
#13 0x40be4e4a in gtk_widget_event () from /usr/lib/libgtk-1.2.so.0
#14 0x40b6ea6f in gtk_propagate_event () from /usr/lib/libgtk-1.2.so.0
#15 0x40b6d7f4 in gtk_main_do_event () from /usr/lib/libgtk-1.2.so.0
#16 0x40c2df15 in gdk_wm_protocols_filter () from /usr/lib/libgdk-1.2.so.0
#17 0x40c649ae in g_get_current_time () from /usr/lib/libglib-1.2.so.0
#18 0x40c64e89 in g_get_current_time () from /usr/lib/libglib-1.2.so.0
#19 0x40c65124 in g_main_run () from /usr/lib/libglib-1.2.so.0
#20 0x40b6d27f in gtk_main () from /usr/lib/libgtk-1.2.so.0
#21 0x4068740e in wxApp::MainLoop() (this=0x8123e78)
    at /space/rpm/BUILD/wxPythonSrc-2.4.2.4/src/gtk/app.cpp:659
#22 0x4025317b in wxPyApp::MainLoop() (this=0x8123e78) at src/helpers.cpp:131
#23 0x4025c802 in _wrap_wxPyApp_MainLoop (self=0x0, args=0x8123f54, kwargs=0x8c7f9d4)
    at src/gtk/wx.cpp:1383
#24 0x080d0e8e in PyCFunction_Call ()
#25 0x080b3797 in PyObject_Call ()
#26 0x0807cb13 in PyEval_GetFuncDesc ()
#27 0x0807aaa1 in PyEval_EvalCode ()
#28 0x0807b0ce in PyEval_EvalCodeEx ()
#29 0x080c447c in PyFunction_SetClosure ()
#30 0x080b3797 in PyObject_Call ()
#31 0x080ba4ab in PyMethod_New ()
#32 0x080b3797 in PyObject_Call ()
#33 0x0807c905 in PyEval_GetFuncDesc ()
#34 0x0807a525 in PyEval_EvalCode ()
#35 0x0807b0ce in PyEval_EvalCodeEx ()
#36 0x0807c62b in PyEval_GetFuncDesc ()
#37 0x0807a5a3 in PyEval_EvalCode ()
#38 0x0807b0ce in PyEval_EvalCodeEx ()
---Type <return> to continue, or q <return> to quit---
#39 0x0807c62b in PyEval_GetFuncDesc ()
#40 0x0807a5a3 in PyEval_EvalCode ()
#41 0x0807b0ce in PyEval_EvalCodeEx ()
#42 0x08077fc5 in PyEval_EvalCode ()
#43 0x08097e29 in PyRun_FileExFlags ()
#44 0x08096d90 in PyRun_SimpleFileExFlags ()
#45 0x080966da in PyRun_AnyFileExFlags ()
#46 0x08053a19 in Py_Main ()
#47 0x08053469 in main ()
#48 0x400b3a67 in __libc_start_main () from /lib/i686/libc.so.6

(gdb) info frame
Stack level 4, frame at 0xbfffe9c8:
eip = 0x407f6852 in wxWindowBase::Close(bool)
    (/space/rpm/BUILD/wxPythonSrc-2.4.2.4/src/common/wincmn.cpp:319); saved eip 0x40666519
called by frame at 0xbfffe9e8, caller of frame at 0xbfffe958
source language c++.
Arglist at 0xbfffe9c8, args: this=0x8cca710, force=true
Locals at 0xbfffe9c8, Previous frame's sp in esp
Saved registers:
  ebx at 0xbfffe9c0, ebp at 0xbfffe9c8, esi at 0xbfffe9c4, eip at 0xbfffe9cc

(gdb) p *this
$4 = {<wxEvtHandler> = {<wxObject> = {_vptr.wxObject = 0x8ca4570, static sm_classwxObject = {
        m_className = 0x408efa6d "wxObject", m_baseClassName1 = 0x0, m_baseClassName2 = 0x0,
        m_objectSize = 8, m_objectConstructor = 0, m_baseInfo1 = 0x0, m_baseInfo2 = 0x0,
        static sm_first = 0x410da300, m_next = 0x40a0a3e0, static sm_classTable = 0x8295e68},
      m_refData = 0xc}, static sm_eventTableEntries = 0x40a06dc0, static sm_eventTable = {
      baseTable = 0x0, entries = 0x40a06dc0}, m_nextHandler = 0x1, m_previousHandler = 0x82ac6c0,
    m_dynamicEvents = 0x0, m_pendingEvents = 0x42600000, m_eventsLocker = 0x0, m_isWindow = false,
    m_enabled = false, {m_clientObject = 0x40000000, m_clientData = 0x40000000},
    m_clientDataType = 1113587712, static sm_classwxEvtHandler = {
      m_className = 0x408e80f3 "wxEvtHandler", m_baseClassName1 = 0x408e80ea "wxObject",
      m_baseClassName2 = 0x0, m_objectSize = 40,
      m_objectConstructor = 0x40730e58 <wxConstructorForwxEvtHandler()>, m_baseInfo1 = 0x40a0a380,
      m_baseInfo2 = 0x0, static sm_first = 0x410da300, m_next = 0x40a06fc0,
      static sm_classTable = 0x8295e68}}, m_windowId = 0, m_parent = 0x0,
  m_children = {<wxListBase> = {<wxObject> = {_vptr.wxObject = 0x0, static sm_classwxObject = {
          m_className = 0x408efa6d "wxObject", m_baseClassName1 = 0x0, m_baseClassName2 = 0x0,
          m_objectSize = 8, m_objectConstructor = 0, m_baseInfo1 = 0x0, m_baseInfo2 = 0x0,
          static sm_first = 0x410da300, m_next = 0x40a0a3e0, static sm_classTable = 0x8295e68},
        m_refData = 0x91}, m_count = 147364816, m_destroy = 80, m_nodeFirst = 0xffffff85,
      m_nodeLast = 0x1, m_keyType = 135278368}, <No data fields>}, m_minWidth = 2, m_minHeight = 2,
  m_maxWidth = 7, m_maxHeight = 147629936, m_eventHandler = 0x80cdd60,
  m_windowValidator = 0x2f399968, m_dropTarget = 0x81cf0f0, m_cursor = {<wxObject> = {
      _vptr.wxObject = 0x82a7d28, static sm_classwxObject = {m_className = 0x408efa6d "wxObject",
        m_baseClassName1 = 0x0, m_baseClassName2 = 0x0, m_objectSize = 8, m_objectConstructor = 0,
        m_baseInfo1 = 0x0, m_baseInfo2 = 0x0, static sm_first = 0x410da300, m_next = 0x40a0a3e0,
        static sm_classTable = 0x8295e68}, m_refData = 0x0}, static sm_classwxCursor = {
      m_className = 0x408d450f "wxCursor", m_baseClassName1 = 0x408d4506 "wxObject",
      m_baseClassName2 = 0x0, m_objectSize = 8,
      m_objectConstructor = 0x40699320 <wxConstructorForwxCursor()>, m_baseInfo1 = 0x40a0a380,
      m_baseInfo2 = 0x0, static sm_first = 0x410da300, m_next = 0x40a05020,
      static sm_classTable = 0x8295e68}}, m_font = {<wxFontBase> = {<wxGDIObject> = {<wxObject> = {
          _vptr.wxObject = 0x0, static sm_classwxObject = {m_className = 0x408efa6d "wxObject",
            m_baseClassName1 = 0x0, m_baseClassName2 = 0x0, m_objectSize = 8,
            m_objectConstructor = 0, m_baseInfo1 = 0x0, m_baseInfo2 = 0x0,
            static sm_first = 0x410da300, m_next = 0x40a0a3e0, static sm_classTable = 0x8295e68},
          m_refData = 0x0}, m_visible = false, static sm_classwxGDIObject = {
          m_className = 0x408d5c29 "wxGDIObject", m_baseClassName1 = 0x408d5c20 "wxObject",
          m_baseClassName2 = 0x0, m_objectSize = 12,
          m_objectConstructor = 0x406b252c <wxConstructorForwxGDIObject()>,
          m_baseInfo1 = 0x40a0a380, m_baseInfo2 = 0x0, static sm_first = 0x410da300,
          m_next = 0x40a052a0, static sm_classTable = 0x8295e68}},
      static ms_encodingDefault = wxFONTENCODING_ISO8859_1}, static sm_classwxFont = {
      m_className = 0x408d5844 "wxFont", m_baseClassName1 = 0x408d5838 "wxGDIObject",
      m_baseClassName2 = 0x0, m_objectSize = 12,
      m_objectConstructor = 0x406acd24 <wxConstructorForwxFont()>, m_baseInfo1 = 0x40a05280,
      m_baseInfo2 = 0x0, static sm_first = 0x410da300, m_next = 0x40a05220,
      static sm_classTable = 0x8295e68}}, m_backgroundColour = {<wxGDIObject> = {<wxObject> = {
        _vptr.wxObject = 0x0, static sm_classwxObject = {m_className = 0x408efa6d "wxObject",
          m_baseClassName1 = 0x0, m_baseClassName2 = 0x0, m_objectSize = 8, m_objectConstructor = 0,
          m_baseInfo1 = 0x0, m_baseInfo2 = 0x0, static sm_first = 0x410da300, m_next = 0x40a0a3e0,
          static sm_classTable = 0x8295e68}, m_refData = 0x0}, m_visible = 75,
---Type <return> to continue, or q <return> to quit---
      static sm_classwxGDIObject = {m_className = 0x408d5c29 "wxGDIObject",
        m_baseClassName1 = 0x408d5c20 "wxObject", m_baseClassName2 = 0x0, m_objectSize = 12,
        m_objectConstructor = 0x406b252c <wxConstructorForwxGDIObject()>, m_baseInfo1 = 0x40a0a380,
        m_baseInfo2 = 0x0, static sm_first = 0x410da300, m_next = 0x40a052a0,
        static sm_classTable = 0x8295e68}}, static sm_classwxColour = {
      m_className = 0x408d4164 "wxColour", m_baseClassName1 = 0x408d4158 "wxGDIObject",
      m_baseClassName2 = 0x0, m_objectSize = 12,
      m_objectConstructor = 0x406944c8 <wxConstructorForwxColour()>, m_baseInfo1 = 0x40a05280,
      m_baseInfo2 = 0x0, static sm_first = 0x410da300, m_next = 0x40a04e20,
      static sm_classTable = 0x8295e68}}, m_foregroundColour = {<wxGDIObject> = {<wxObject> = {
        _vptr.wxObject = 0x8300370, static sm_classwxObject = {m_className = 0x408efa6d "wxObject",
          m_baseClassName1 = 0x0, m_baseClassName2 = 0x0, m_objectSize = 8, m_objectConstructor = 0,
          m_baseInfo1 = 0x0, m_baseInfo2 = 0x0, static sm_first = 0x410da300, m_next = 0x40a0a3e0,
          static sm_classTable = 0x8295e68}, m_refData = 0x810f7a0}, m_visible = false,
      static sm_classwxGDIObject = {m_className = 0x408d5c29 "wxGDIObject",
        m_baseClassName1 = 0x408d5c20 "wxObject", m_baseClassName2 = 0x0, m_objectSize = 12,
        m_objectConstructor = 0x406b252c <wxConstructorForwxGDIObject()>, m_baseInfo1 = 0x40a0a380,
        m_baseInfo2 = 0x0, static sm_first = 0x410da300, m_next = 0x40a052a0,
        static sm_classTable = 0x8295e68}}, static sm_classwxColour = {
      m_className = 0x408d4164 "wxColour", m_baseClassName1 = 0x408d4158 "wxGDIObject",
      m_baseClassName2 = 0x0, m_objectSize = 12,
      m_objectConstructor = 0x406944c8 <wxConstructorForwxColour()>, m_baseInfo1 = 0x40a05280,
      m_baseInfo2 = 0x0, static sm_first = 0x410da300, m_next = 0x40a04e20,
      static sm_classTable = 0x8295e68}}, m_caret = 0x0,
  m_updateRegion = {<wxGDIObject> = {<wxObject> = {_vptr.wxObject = 0x0, static sm_classwxObject = {
          m_className = 0x408efa6d "wxObject", m_baseClassName1 = 0x0, m_baseClassName2 = 0x0,
          m_objectSize = 8, m_objectConstructor = 0, m_baseInfo1 = 0x0, m_baseInfo2 = 0x0,
          static sm_first = 0x410da300, m_next = 0x40a0a3e0, static sm_classTable = 0x8295e68},
        m_refData = 0x0}, m_visible = false, static sm_classwxGDIObject = {
        m_className = 0x408d5c29 "wxGDIObject", m_baseClassName1 = 0x408d5c20 "wxObject",
        m_baseClassName2 = 0x0, m_objectSize = 12,
        m_objectConstructor = 0x406b252c <wxConstructorForwxGDIObject()>, m_baseInfo1 = 0x40a0a380,
        m_baseInfo2 = 0x0, static sm_first = 0x410da300, m_next = 0x40a052a0,
        static sm_classTable = 0x8295e68}}, static sm_classwxRegion = {
      m_className = 0x408d72e4 "wxRegion", m_baseClassName1 = 0x408d72d8 "wxGDIObject",
      m_baseClassName2 = 0x0, m_objectSize = 12,
      m_objectConstructor = 0x406ca8a8 <wxConstructorForwxRegion()>, m_baseInfo1 = 0x40a05280,
      m_baseInfo2 = 0x0, static sm_first = 0x410da300, m_next = 0x40a055c0,
      static sm_classTable = 0x8295e68}}, m_acceleratorTable = {<wxObject> = {_vptr.wxObject = 0x0,
      static sm_classwxObject = {m_className = 0x408efa6d "wxObject", m_baseClassName1 = 0x0,
        m_baseClassName2 = 0x0, m_objectSize = 8, m_objectConstructor = 0, m_baseInfo1 = 0x0,
        m_baseInfo2 = 0x0, static sm_first = 0x410da300, m_next = 0x40a0a3e0,
        static sm_classTable = 0x8295e68}, m_refData = 0x0}, static sm_classwxAcceleratorTable = {
      m_className = 0x408caea4 "wxAcceleratorTable", m_baseClassName1 = 0x408cae9b "wxObject",
      m_baseClassName2 = 0x0, m_objectSize = 8,
      m_objectConstructor = 0x405bdc88 <wxConstructorForwxAcceleratorTable()>,
      m_baseInfo1 = 0x40a0a380, m_baseInfo2 = 0x0, static sm_first = 0x410da300,
      m_next = 0x40a01320, static sm_classTable = 0x8295e68}}, m_tooltip = 0x0, m_constraints = 0x0,
  m_constraintsInvolvedIn = 0x0, m_windowSizer = 0x0, m_containingSizer = 0x0, m_autoLayout = false,
  m_isShown = false, m_isEnabled = false, m_isBeingDeleted = false, m_hasBgCol = false,
  m_hasFgCol = false, m_hasFont = false, m_windowStyle = 33, m_exStyle = 51733, m_windowName = {
---Type <return> to continue, or q <return> to quit---
    m_pchData = 0x40bfc768 "tab_pack", static npos = 4294967195}, m_themeEnabled = 4,
  m_palette = {<wxGDIObject> = {<wxObject> = {_vptr.wxObject = 0x13, static sm_classwxObject = {
          m_className = 0x408efa6d "wxObject", m_baseClassName1 = 0x0, m_baseClassName2 = 0x0,
          m_objectSize = 8, m_objectConstructor = 0, m_baseInfo1 = 0x0, m_baseInfo2 = 0x0,
          static sm_first = 0x410da300, m_next = 0x40a0a3e0, static sm_classTable = 0x8295e68},
        m_refData = 0x40bfc75b}, m_visible = 6, static sm_classwxGDIObject = {
        m_className = 0x408d5c29 "wxGDIObject", m_baseClassName1 = 0x408d5c20 "wxObject",
        m_baseClassName2 = 0x0, m_objectSize = 12,
        m_objectConstructor = 0x406b252c <wxConstructorForwxGDIObject()>, m_baseInfo1 = 0x40a0a380,
        m_baseInfo2 = 0x0, static sm_first = 0x410da300, m_next = 0x40a052a0,
        static sm_classTable = 0x8295e68}}, static sm_classwxPalette = {
      m_className = 0x408d1114 "wxPalette", m_baseClassName1 = 0x408d1108 "wxGDIObject",
      m_baseClassName2 = 0x0, m_objectSize = 12,
      m_objectConstructor = 0x4063e218 <wxConstructorForwxPalette()>, m_baseInfo1 = 0x40a05280,
      m_baseInfo2 = 0x0, static sm_first = 0x410da300, m_next = 0x40a03300,
      static sm_classTable = 0x8295e68}}, m_hasCustomPalette = 5, m_virtualSize = {x = 33, y = 0},
  m_minVirtualWidth = 0, m_minVirtualHeight = 0, m_maxVirtualWidth = 0, m_maxVirtualHeight = 0,
  static ms_lastControlId = -345, static ms_winCaptureNext = 0x0, static sm_classwxWindowBase = {
    m_className = 0x408f4bba "wxWindowBase", m_baseClassName1 = 0x408f4bad "wxEvtHandler",
    m_baseClassName2 = 0x0, m_objectSize = 252, m_objectConstructor = 0, m_baseInfo1 = 0x40a06920,
    m_baseInfo2 = 0x0, static sm_first = 0x410da300, m_next = 0x40a0b4e0,
    static sm_classTable = 0x8295e68}, static sm_eventTableEntries = 0x40a0b460,
  static sm_eventTable = {baseTable = 0x40951eec, entries = 0x40a0b460}}

Roger

Roger Binns wrote:

Can you refactor things such that the main frame is not created until
you are ready to show it, IOW, after the config has been checked and the
dialog possibly shown modally? For example, the demo main frame is not
created until the EVT_CLOSE handler of the splash screen.

Constructing the main frame takes quite a while as 6 notebook
pages get loaded, many images may be converted, and who knows
what else is loaded. It is currently written so that lots of
work is done, then the config is checked, then any more work
that depends on the config is done.

Is there any other workaround you can think of,

Not without having a sample to play with... Perhaps using wxCallAfter somewhere so some things are delayed until after the app is fully initialized?

I can change around things, and am even happy to ignore user
presses on the splashscreen as that seems to cause the problem.

That sounds like the simplest thing to do however.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!