[ wxwindows-Bugs-1874290 ] Debugging code with a menu bar crashes program...

SourceForge.net noreply at sourceforge.net
Mon Mar 3 11:03:34 PST 2008


Bugs item #1874290, was opened at 2008-01-17 18:12
Message generated for change (Comment added) made by robind
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1874290&group_id=9863

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: wxMac specific
Group: None
Status: Open
Resolution: Fixed
Priority: 5
Private: No
Submitted By: Douglas Anderson (dianders)
Assigned to: Stefan Csomor (csomor)
Summary: Debugging code with a menu bar crashes program...

Initial Comment:
This one has been bugging me for a while, and I finally put my finger on it!  Sometimes, while debugging with Komodo, my program will just "randomly" crash.  I always attributed it to a Komodo bug, but I finally found that it's a wx bug.  ...at least in this one instance.


The problem stems from the fact that Komodo evaluates all of the attributes of any local variable when you're stepping through code.  This is normally OK.  However, stepping through all of the attributes of a wx.MenuBar causes the program to crash with a bus error!


I know you probably don't care about Komodo, but this is a major enough problem and is easy to reproduce even without Komodo.  Just do this:

---

import wx

def main():
    app = wx.PySimpleApp()
    f = wx.Frame(None, -1, "DisableMenuTest")
    menuBar = wx.MenuBar()
    print "I want to crash"
    print menuBar.BestSize

if __name__ == '__main__':
    main()

---

There are several attributes that will cause a similar crash, including 'BestVirtualSize' and 'CharHeight'.  I found them by doing this, which is probably just like what Komodo does:

for s in dir(menuBar):
    print getattr(menuBar, s)


---

This problem _doesn't_ manifest itself on Windows.



Thanks!

-Doug

----------------------------------------------------------------------

>Comment By: Robin Dunn (robind)
Date: 2008-03-03 11:03

Message:
Logged In: YES 
user_id=53955
Originator: NO

> ProgressDialogProblem: fixed by Robin (thanks!), though the ".i" files
> weren't updated in subversion.

Correct.  I was waiting for some other changes to be completed before
committing the generated files.  Sorry for the confusion.


----------------------------------------------------------------------

Comment By: Douglas Anderson (dianders)
Date: 2008-03-03 10:59

Message:
Logged In: YES 
user_id=47448
Originator: YES

OK, running with a fixed SWIG worked and showed that Robin's fix was
good.

To summarize:

MenuBar problem: fixed by Stefan (thanks!)
ProgressDialogProblem: fixed by Robin (thanks!), though the ".i" files
weren't updated in subversion.

----------------------------------------------------------------------

Comment By: Douglas Anderson (dianders)
Date: 2008-03-03 10:40

Message:
Logged In: YES 
user_id=47448
Originator: YES

...swig thing looks like my fault--I need to patch swig.  I'll do that and
get back to you...

----------------------------------------------------------------------

Comment By: Douglas Anderson (dianders)
Date: 2008-03-03 10:29

Message:
Logged In: YES 
user_id=47448
Originator: YES

Stefan,

I have managed to build the wx sources from the SVN repository and
verified that the menubar problem is fixed.  Thanks!  This will be very
helpful!


Robin,

My build still showed problems when debugging w/ progress dialogs.  It
appeared that progress dialogs still had a "StatusBar" attribute.  My guess
was that I needed to re-generate my '.i' files, but when I tried
re-building with SWIG, I got the following when running my test:
  AttributeError: 'module' object has no attribute 'ID_ANY'
...so I'm clearly doing something wrong.

----------------------------------------------------------------------

Comment By: Robin Dunn (robind)
Date: 2008-03-01 11:13

Message:
Logged In: YES 
user_id=53955
Originator: NO

ProgressDialog.ToolBar is a wxPython-only problem.  For some reason I
indicated that it derived from wx.Frame instead of wx.Dialog, so the Python
class was inheriting a bunch of things that the C++ class couldn't handle. 
Fixed now. 

----------------------------------------------------------------------

Comment By: Stefan Csomor (csomor)
Date: 2008-03-01 08:48

Message:
Logged In: YES 
user_id=81467
Originator: NO

Hi

this is a different setup, in dlg.ToolBar you are asking for an attribute
that plainly doesn't exist, at least not in c++... 

I've tried to solve the original problem by guarding things in window.cpp
against the menubar case, committed to 2.8, please verify after rebuilding
wxpython

Thanks,

Stefan

----------------------------------------------------------------------

Comment By: Douglas Anderson (dianders)
Date: 2008-02-29 14:04

Message:
Logged In: YES 
user_id=47448
Originator: YES

Stefan,

In case it's useful to you (or anyone else who might tackle this bug),
there's a similar problem with ProgressDialog with the "ToolBar"
attribute:

    app = wx.PySimpleApp()
    dlg = wx.ProgressDialog("hi", "there")
    print "I want to crash"
    print dlg.ToolBar

-Doug

----------------------------------------------------------------------

Comment By: Douglas Anderson (dianders)
Date: 2008-01-22 17:35

Message:
Logged In: YES 
user_id=47448
Originator: YES

Hi Stefan,

...your wish is my command.  Here are new steps to reproduce for you
without using Komodo...

1. Open 'PyCrust.app'.

2. Type the following commands:
>>> import wx
>>> app = wx.PySimpleApp()
>>> f = wx.Frame(None, -1, "DisableMenuTest")
>>> menuBar = wx.MenuBar()

3. Open the 'locals' (click the triangle to the left of locals).

Expect: to see local variables
Actual: pycrust crashes.


Thanks,

Doug

----------------------------------------------------------------------

Comment By: Stefan Csomor (csomor)
Date: 2008-01-19 00:51

Message:
Logged In: YES 
user_id=81467
Originator: NO

Hi Robin

thanks for the clarification, I already feared that, because while we kept
telling people not to use certain calls on a menubar, we cannot tell
kommodo ... although if they'd use wxwidgets for the ide, I'd be more
motivated to fix it ;-)

Thanks,

Stefan

----------------------------------------------------------------------

Comment By: Robin Dunn (robind)
Date: 2008-01-18 09:42

Message:
Logged In: YES 
user_id=53955
Originator: NO

Stefan, those attributes are actually Python properties that use the
standard getter methods to get the values.  Since wxMenuBar inherits from
wxWindow it is also inheriting those properties in the Python proxy
classes.  So apparently you can probably duplicate this bug by calling
GetCharHeight on a menubar instance. 

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1874290&group_id=9863




More information about the wx-dev mailing list