Segmenation fault when exiting app

wxpy 2.8.1.1 and unicode on gtk, kde

DrPyhton

Problem:
I start DrPython, open some files, click on random tabs (documents),
then FINALLY click on the FIRST tab => exit => everything ok
I start DrPython, open some files, click on all other file except the FIRST tab => segmentation fault on exit

As Robin suggested, I ran gdb:

then did a backtrace.

I hope this listing helps! :slight_smile:

gdb python

(gdb) run
Starting program: /usr/bin/python
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
[New Thread -1210354000 (LWP 5270)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
Python 2.4.4c1 (#2, Oct 11 2006, 21:51:02)
[GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(no debugging symbols found)

import drpython
drpython.main()

[New Thread -1249428576 (LWP 5273)]
[New Thread -1257821280 (LWP 5274)]
[Thread -1249428576 (LWP 5273) exited]
[Thread -1257821280 (LWP 5274) exited]
fixed
[New Thread -1249428576 (LWP 5275)]
[New Thread -1257821280 (LWP 5276)]
[Thread -1249428576 (LWP 5275) exited]
[Thread -1257821280 (LWP 5276) exited]
[New Thread -1257821280 (LWP 5277)]
[New Thread -1249428576 (LWP 5278)]
[Thread -1249428576 (LWP 5278) exited]
[Thread -1257821280 (LWP 5277) exited]
[New Thread -1257821280 (LWP 5279)]
[New Thread -1249428576 (LWP 5280)]
[Thread -1249428576 (LWP 5280) exited]
[Thread -1257821280 (LWP 5279) exited]
[New Thread -1257821280 (LWP 5281)]
[New Thread -1249428576 (LWP 5282)]
[Thread -1249428576 (LWP 5282) exited]
[Thread -1257821280 (LWP 5281) exited]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1210354000 (LWP 5270)]
0x00000000 in ?? ()
(gdb) backtrace
#0 0x00000000 in ?? ()
#1 0xb62a1b2d in wxPyPreviewControlBar::SetZoomControl ()
   from /usr/lib/python2.4/site-packages/wx-2.8-gtk2-unicode/wx/_windows_.so
#2 0x08058c27 in PyObject_Call ()
#3 0x080b7bd2 in PyEval_EvalFrame ()
#4 0x080ba4b9 in PyEval_EvalCodeEx ()
#5 0x080b86ea in PyEval_EvalFrame ()
#6 0x080b8d94 in PyEval_EvalFrame ()
#7 0x080b8d94 in PyEval_EvalFrame ()
#8 0x080ba4b9 in PyEval_EvalCodeEx ()
#9 0x08101f71 in PyClassMethod_New ()
#10 0x08058c27 in PyObject_Call ()
#11 0x0805e4f4 in PyClass_IsSubclass ()
#12 0x08058c27 in PyObject_Call ()
#13 0x080b395c in PyEval_CallObjectWithKeywords ()
#14 0xb79bb394 in wxPyCallback::EventThunker ()
   from /usr/lib/python2.4/site-packages/wx-2.8-gtk2-unicode/wx/_core_.so
#15 0xb72af48f in wxAppConsole::HandleEvent ()
   from /usr/lib/libwx_baseu-2.8.so.0
#16 0xb73516bc in wxEvtHandler::ProcessEventIfMatches ()
   from /usr/lib/libwx_baseu-2.8.so.0
#17 0xb7351778 in wxEvtHandler::SearchDynamicEventTable ()
   from /usr/lib/libwx_baseu-2.8.so.0
---Type <return> to continue, or q <return> to quit---
#18 0xb7351a1a in wxEvtHandler::ProcessEvent ()
   from /usr/lib/libwx_baseu-2.8.so.0
#19 0xb760999e in wxNotebookBase::SendPageChangedEvent ()
   from /usr/lib/libwx_gtk2u_core-2.8.so.0
#20 0xb758dee5 in wxMessageDialog::DoMoveWindow ()
   from /usr/lib/libwx_gtk2u_core-2.8.so.0
#21 0xb6c4db4d in _gtk_marshal_VOID__POINTER_UINT ()
   from /usr/lib/libgtk-x11-2.0.so.0
#22 0xb70a779b in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#23 0xb70b7e81 in g_signal_chain_from_overridden ()
   from /usr/lib/libgobject-2.0.so.0
#24 0xb70b90b7 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#25 0xb70b9279 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#26 0xb6c6625e in gtk_notebook_set_homogeneous_tabs ()
   from /usr/lib/libgtk-x11-2.0.so.0
#27 0xb6c6bf57 in gtk_notebook_new () from /usr/lib/libgtk-x11-2.0.so.0
#28 0xb70b4039 in g_cclosure_marshal_VOID__OBJECT ()
   from /usr/lib/libgobject-2.0.so.0
#29 0xb70a5fb9 in g_value_set_boxed () from /usr/lib/libgobject-2.0.so.0
#30 0xb70a779b in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#31 0xb70b802a in g_signal_chain_from_overridden ()
   from /usr/lib/libgobject-2.0.so.0
#32 0xb70b90b7 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
---Type <return> to continue, or q <return> to quit---
#33 0xb70b9279 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#34 0xb6bbbe89 in gtk_container_remove () from /usr/lib/libgtk-x11-2.0.so.0
#35 0xb6c654fa in gtk_notebook_remove_page () from /usr/lib/libgtk-x11-2.0.so.0
#36 0xb758e9c6 in wxNotebook::DoRemovePage ()
   from /usr/lib/libwx_gtk2u_core-2.8.so.0
#37 0xb75aa116 in wxBookCtrlBase::DeletePage ()
   from /usr/lib/libwx_gtk2u_core-2.8.so.0
#38 0xb758f153 in wxNotebook::DeleteAllPages ()
   from /usr/lib/libwx_gtk2u_core-2.8.so.0
#39 0xb75901b2 in wxNotebook::~wxNotebook ()
   from /usr/lib/libwx_gtk2u_core-2.8.so.0
#40 0xb7632ac9 in wxWindowBase::DestroyChildren ()
   from /usr/lib/libwx_gtk2u_core-2.8.so.0
#41 0xb751d272 in wxWindow::~wxWindow ()
   from /usr/lib/libwx_gtk2u_core-2.8.so.0
#42 0xb77be4be in wxSashWindow::~wxSashWindow ()
   from /usr/lib/libwx_gtk2u_adv-2.8.so.0
#43 0xb7632ac9 in wxWindowBase::DestroyChildren ()
   from /usr/lib/libwx_gtk2u_core-2.8.so.0
#44 0xb751d272 in wxWindow::~wxWindow ()
   from /usr/lib/libwx_gtk2u_core-2.8.so.0
#45 0xb765dd67 in wxPanel::~wxPanel () from /usr/lib/libwx_gtk2u_core-2.8.so.0
#46 0xb7632ac9 in wxWindowBase::DestroyChildren ()
---Type <return> to continue, or q <return> to quit---
   from /usr/lib/libwx_gtk2u_core-2.8.so.0
#47 0xb751d272 in wxWindow::~wxWindow ()
   from /usr/lib/libwx_gtk2u_core-2.8.so.0
#48 0xb762d6a2 in wxTopLevelWindowBase::~wxTopLevelWindowBase ()
   from /usr/lib/libwx_gtk2u_core-2.8.so.0
#49 0xb7512c0e in wxTopLevelWindowGTK::~wxTopLevelWindowGTK ()
   from /usr/lib/libwx_gtk2u_core-2.8.so.0
#50 0xb75ddc77 in wxFrameBase::~wxFrameBase ()
   from /usr/lib/libwx_gtk2u_core-2.8.so.0
#51 0xb7573b17 in wxFrame::~wxFrame () from /usr/lib/libwx_gtk2u_core-2.8.so.0
#52 0xb75a682b in wxAppBase::DeletePendingObjects ()
   from /usr/lib/libwx_gtk2u_core-2.8.so.0
#53 0xb75a6864 in wxAppBase::OnIdle () from /usr/lib/libwx_gtk2u_core-2.8.so.0
#54 0xb72af48f in wxAppConsole::HandleEvent ()
   from /usr/lib/libwx_baseu-2.8.so.0
#55 0xb73516bc in wxEvtHandler::ProcessEventIfMatches ()
   from /usr/lib/libwx_baseu-2.8.so.0
#56 0xb735188e in wxEventHashTable::HandleEvent ()
   from /usr/lib/libwx_baseu-2.8.so.0
#57 0xb7351a36 in wxEvtHandler::ProcessEvent ()
   from /usr/lib/libwx_baseu-2.8.so.0
#58 0xb75a6b02 in wxAppBase::ProcessIdle ()
   from /usr/lib/libwx_gtk2u_core-2.8.so.0
---Type <return> to continue, or q <return> to quit---
#59 0xb74edae3 in wxApp::Initialize () from /usr/lib/libwx_gtk2u_core-2.8.so.0
#60 0xb6e95aa1 in g_source_is_destroyed () from /usr/lib/libglib-2.0.so.0
#61 0xb6e97802 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#62 0xb6e9a7df in g_main_context_check () from /usr/lib/libglib-2.0.so.0
#63 0xb6e9ab89 in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
#64 0xb6c4b574 in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0
#65 0xb7507a44 in wxEventLoop::Run () from /usr/lib/libwx_gtk2u_core-2.8.so.0
#66 0xb75a6287 in wxAppBase::MainLoop ()
   from /usr/lib/libwx_gtk2u_core-2.8.so.0
#67 0xb79b5eea in wxPyApp::MainLoop ()
   from /usr/lib/python2.4/site-packages/wx-2.8-gtk2-unicode/wx/_core_.so
#68 0xb79f5706 in wxIntersectRect ()
   from /usr/lib/python2.4/site-packages/wx-2.8-gtk2-unicode/wx/_core_.so
#69 0x08058c27 in PyObject_Call ()
#70 0x080b7bd2 in PyEval_EvalFrame ()
#71 0x080ba4b9 in PyEval_EvalCodeEx ()
#72 0x08101f71 in PyClassMethod_New ()
#73 0x08058c27 in PyObject_Call ()
#74 0x0805e4f4 in PyClass_IsSubclass ()
#75 0x08058c27 in PyObject_Call ()
#76 0x080b65c3 in PyEval_EvalFrame ()
#77 0x080b8d94 in PyEval_EvalFrame ()
#78 0x080b8d94 in PyEval_EvalFrame ()
---Type <return> to continue, or q <return> to quit---
#79 0x080ba4b9 in PyEval_EvalCodeEx ()
#80 0x080ba527 in PyEval_EvalCode ()
#81 0x080dd345 in PyRun_InteractiveOneFlags ()
#82 0x080dd466 in PyRun_InteractiveLoopFlags ()
#83 0x080ddf72 in PyRun_AnyFileExFlags ()
#84 0x08055cc2 in Py_Main ()
#85 0x08055132 in main ()
(gdb)

路路路

--
Franz Steinhaeusler

Sorry for getting a little OT.
Is there anything else (I don't know gdb so good) to extract even more information.

the backtrace is not the stack, isn't it. How can I get the stack or even maybe what window
or frames were open at that time (This I think is not possible)?

路路路

On Tue, 24 Apr 2007 09:19:23 +0200, Franz Steinhaeusler <franz.steinhaeusler@gmx.at> wrote:

On Mon, 23 Apr 2007 13:06:26 -0700, Robin Dunn <robin@alldunn.com> wrote:

Franz Steinh盲usler wrote:

wxpy 2.8.1.1 and unicode on gtk, kde

DrPyhton

Problem:
I start DrPython, open some files, click on random tabs (documents),
then FINALLY click on the FIRST tab => exit => everything ok
I start DrPython, open some files, click on all other file except the FIRST tab => segmentation fault on exit

(gdb) backtrace
#0 0x00000000 in ?? ()
#1 0xb62a1b2d in wxPyPreviewControlBar::SetZoomControl ()
   from /usr/lib/python2.4/site-packages/wx-2.8-gtk2-unicode/wx/_windows_.so

Do you have a print preview frame that still exists when the app exits?

Hm, I searched the source code, there is one htmleasprinting, but if I comment this out
(no instance) nothing changes. I will investigate further...

--

Franz Steinhaeusler

Franz Steinhaeusler wrote:

Sorry for getting a little OT.
Is there anything else (I don't know gdb so good) to extract even more information.

the backtrace is not the stack, isn't it.

It shows the C++ call stack, but not the data values on the stack.

Ok.

Meanwhile I could figure out the culprit. :slight_smile:

In easy words:

(It happens only on gtk, windows seems to be more "robust" in that way or handles this in another way.

If I'm wrong, please correct me
When the Program exits, the frame is being destroyed.
In the run of this procedure, the notebook tabs are destroyes, and in that process, event page changed is called.
In the procedure of the pageeventchanged, the statustext was updated via SetStatusText of the frame.
That lead to a segmentation fault. I looked how to check, if the frame is "valid". I found the promising function IsBeingDeleted
and applied it that way:

in OnNotebookTabChanged:
        if not self.grandparent.IsBeingDeleted():
            self.grandparent.txtDocumentArray[i].OnModified(None)

    #in that function, the status bar is updated;
       #self.grandparent.txtDocumentArray[i] is a styled text control.

Would you solve that in another way or is it right so?

How can I get the stack or even maybe what window
or frames were open at that time (This I think is not possible)?

It probably is, but is gdb black magic (IOW, not easy to explain or to do.)

Thanks for the info and the help of finding the bug. :wink:

路路路

On Tue, 24 Apr 2007 10:45:40 -0700, Robin Dunn <robin@alldunn.com> wrote:
--
Franz Steinhaeusler

Franz Steinh盲usler wrote:

Franz Steinhaeusler wrote:

Sorry for getting a little OT.
Is there anything else (I don't know gdb so good) to extract even more information.

the backtrace is not the stack, isn't it.

It shows the C++ call stack, but not the data values on the stack.

Ok.

Meanwhile I could figure out the culprit. :slight_smile:

In easy words:

(It happens only on gtk, windows seems to be more "robust" in that way or handles this in another way.

It's probably a difference of the order events are being sent, or if they are sent at all during shutdown.

If I'm wrong, please correct me
When the Program exits, the frame is being destroyed.
In the run of this procedure, the notebook tabs are destroyes, and in that process, event page changed is called.
In the procedure of the pageeventchanged, the statustext was updated via SetStatusText of the frame.
That lead to a segmentation fault. I looked how to check, if the frame is "valid". I found the promising function IsBeingDeleted
and applied it that way:

in OnNotebookTabChanged:
        if not self.grandparent.IsBeingDeleted():
            self.grandparent.txtDocumentArray[i].OnModified(None)

    #in that function, the status bar is updated; #self.grandparent.txtDocumentArray[i] is a styled text control.

Would you solve that in another way or is it right so?

Yes, that looks correct. You could probably also check either of these conditions:

  if self.grandparent:
    ...

  if not self.IsBeingDeleted():
    ...

路路路

On Tue, 24 Apr 2007 10:45:40 -0700, Robin Dunn <robin@alldunn.com> wrote:

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

Franz Steinh盲usler wrote:

Franz Steinhaeusler wrote:

Sorry for getting a little OT.
Is there anything else (I don't know gdb so good) to extract even more information.

the backtrace is not the stack, isn't it.

It shows the C++ call stack, but not the data values on the stack.

Ok.

Meanwhile I could figure out the culprit. :slight_smile:

In easy words:

(It happens only on gtk, windows seems to be more "robust" in that way or handles this in another way.

It's probably a difference of the order events are being sent, or if
they are sent at all during shutdown.

I see.

If I'm wrong, please correct me
When the Program exits, the frame is being destroyed.
In the run of this procedure, the notebook tabs are destroyes, and in that process, event page changed is called.
In the procedure of the pageeventchanged, the statustext was updated via SetStatusText of the frame.
That lead to a segmentation fault. I looked how to check, if the frame is "valid". I found the promising function IsBeingDeleted
and applied it that way:

in OnNotebookTabChanged:
        if not self.grandparent.IsBeingDeleted():
            self.grandparent.txtDocumentArray[i].OnModified(None)

    #in that function, the status bar is updated;
       #self.grandparent.txtDocumentArray[i] is a styled text control.

Would you solve that in another way or is it right so?

Yes, that looks correct. You could probably also check either of these
conditions:

if self.grandparent:
  ...

if not self.IsBeingDeleted():
  ...

Thanks, Is it possible to catch such things better in wxWidgets or even in wxPython to make
a fix easier and faster? :slight_smile:

路路路

On Wed, 25 Apr 2007 14:16:56 -0700, Robin Dunn <robin@alldunn.com> wrote:

On Tue, 24 Apr 2007 10:45:40 -0700, Robin Dunn <robin@alldunn.com> wrote:

--

Franz Steinhaeusler