segfault in wxPython "showcase"

"rantingrick" has published a small script on comp.lang.python that should
demonstrate the superiority of wxPython over Tkinter. That somewhat
backfired as several people who tried to run it on linux encountered a
segfault.

One report:
http://mail.python.org/pipermail/python-list/2011-January/1264579.html

The code in question:
https://sites.google.com/site/thefutureofpython/home/code-challenges

Is it a problem with the script, a wxPython bug, or a problem with the
platform? It would be nice if a wxPython expert could have a look at the
code.

Peter

Hi Peter,

"rantingrick" has published a small script on comp.lang.python that should
demonstrate the superiority of wxPython over Tkinter. That somewhat
backfired as several people who tried to run it on linux encountered a
segfault.

One report:
http://mail.python.org/pipermail/python-list/2011-January/1264579.html

The code in question:
https://sites.google.com/site/thefutureofpython/home/code-challenges

Is it a problem with the script, a wxPython bug, or a problem with the
platform? It would be nice if a wxPython expert could have a look at the
code.

Pity that they can't talk nicely with each other about this challenge, no?

The code runs as is on my Windows 7 box with Python 2.6, wxPython 2.8.11, tried to run it on my Ubuntu box but on there it crashes and when I debug it on there it does so on line 151 which is:

             index = self.InsertImageStringItem(idx, name, imageIdx)

idx = contains an int
name = contains a file name
imageIdx = contains a valid index to the image list which is attached to the listctrl.

No idea why wxPython on Ubuntu (probably Linux) has a problem with that line.

Hopefully some *nix expert can help with this.

Werner

···

On 24/01/2011 11:09, Peter Otten wrote:

Peter

While I like wxPython more than Tkinter, Rick sounds like he's just
stirring up trouble. I'm pretty sure the reason that wx is NOT
included is because Guido said that wx gets updated too often between
Python updates. I'm not sure that's a valid argument, but wx would
definitely add a lot to the size of Python.

I have never seen that guy on our list either.

···

On Jan 24, 4:09 am, Peter Otten <__pete...@web.de> wrote:

"rantingrick" has published a small script on comp.lang.python that should
demonstrate the superiority of wxPython over Tkinter. That somewhat
backfired as several people who tried to run it on linux encountered a
segfault.

One report:http://mail.python.org/pipermail/python-list/2011-January/1264579.html

The code in question:https://sites.google.com/site/thefutureofpython/home/code-challenges

Is it a problem with the script, a wxPython bug, or a problem with the
platform? It would be nice if a wxPython expert could have a look at the
code.

Peter

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

It crashed on OS-X, too, though not right away. I don't have the energy to look any more at it, and that guy is a raving lunatic (I hope folks don't think he is representative of what is a wonderful wxPython community)

But -- it is too bad -- non Python code should crash the interpreter, so there is a bug or two in wx with that one. They are not common, but they do exist.

I've been a wx user and fan for along time, but I'm not sure it should be in the std lib. I'm not sure TK should either -- it would be nice to have truly pythonic GUI toolkit in there some day -- maybe pyGUI? who knows? it's a monstrous task.

-oh well,

-Chris

···

On 1/24/11 6:24 AM, werner wrote:

On 24/01/2011 11:09, Peter Otten wrote:

"rantingrick" has published a small script on comp.lang.python that
should
demonstrate the superiority of wxPython over Tkinter. That somewhat
backfired as several people who tried to run it on linux encountered a
segfault.

One report:
http://mail.python.org/pipermail/python-list/2011-January/1264579.html

The code in question:
https://sites.google.com/site/thefutureofpython/home/code-challenges

The code runs as is on my Windows 7 box with Python 2.6, wxPython
2.8.11, tried to run it on my Ubuntu box but on there it crashes and
when I debug it on there it does so on line 151 which is:

--
Christopher Barker, P.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

That guy definitely sounds like a troll. I only commented on his
thread to make clear that he's not one of us. I like the "challenge"
concept, but not the way he's going about it.

···

On Jan 24, 11:29 am, Christopher Barker <Chris.Bar...@noaa.gov> wrote:

On 1/24/11 6:24 AM, werner wrote:

> On 24/01/2011 11:09, Peter Otten wrote:
>> "rantingrick" has published a small script on comp.lang.python that
>> should
>> demonstrate the superiority of wxPython over Tkinter. That somewhat
>> backfired as several people who tried to run it on linux encountered a
>> segfault.

>> One report:
>>http://mail.python.org/pipermail/python-list/2011-January/1264579.html

>> The code in question:
>>https://sites.google.com/site/thefutureofpython/home/code-challenges
> The code runs as is on my Windows 7 box with Python 2.6, wxPython
> 2.8.11, tried to run it on my Ubuntu box but on there it crashes and
> when I debug it on there it does so on line 151 which is:

It crashed on OS-X, too, though not right away. I don't have the energy
to look any more at it, and that guy is a raving lunatic (I hope folks
don't think he is representative of what is a wonderful wxPython community)

But -- it is too bad -- non Python code should crash the interpreter, so
there is a bug or two in wx with that one. They are not common, but they
do exist.

I've been a wx user and fan for along time, but I'm not sure it should
be in the std lib. I'm not sure TK should either -- it would be nice to
have truly pythonic GUI toolkit in there some day -- maybe pyGUI? who
knows? it's a monstrous task.

-oh well,

-Chris

--
Christopher Barker, P.D.
Oceanographer

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

Do not forget IDLE.
For a Windows user, it's the only way to have a decent console,
interactive interpreter, out of the box.
For a Linux user, syntax highlighter, colorazing... are probably
welcome.
OSX? Probably, like Linux (I don't kwow).

jmf

···

On Jan 24, 6:29 pm, Christopher Barker <Chris.Bar...@noaa.gov> wrote:

On 1/24/11 6:24 AM, werner wrote:

...
      I'm not sure TK should either

My reply: http://groups.google.com/group/comp.lang.python/msg/66c75d9d8f962aad

···

On 1/24/11 2:09 AM, Peter Otten wrote:

"rantingrick" has published a small script on comp.lang.python that should
demonstrate the superiority of wxPython over Tkinter. That somewhat
backfired as several people who tried to run it on linux encountered a
segfault.

One report:
http://mail.python.org/pipermail/python-list/2011-January/1264579.html

The code in question:
https://sites.google.com/site/thefutureofpython/home/code-challenges

Is it a problem with the script, a wxPython bug, or a problem with the
platform? It would be nice if a wxPython expert could have a look at the
code.

--
Robin Dunn
Software Craftsman

While I like wxPython more than Tkinter, Rick sounds like he's just
stirring up trouble. I'm pretty sure the reason that wx is NOT
included is because Guido said that wx gets updated too often between
Python updates. I'm not sure that's a valid argument,

It's not as true now as it was when Guido made the comment. Python's release cycles has sped up and wxPython's have slowed down. But I still agree with the underlying principle. Tk is fine for a "batteries included" approach, OTOH wx compared to that battery is more like a hydrogen fuel cell. It's a lot more powerful and can do a lot more but is not something that everybody could use in the flashlight they carry around in their pocket.

but wx would
definitely add a lot to the size of Python.

More than double it probably.

···

On 1/24/11 6:33 AM, Mike Driscoll wrote:

--
Robin Dunn
Software Craftsman

Robin Dunn wrote:

···

On 1/24/11 2:09 AM, Peter Otten wrote:

"rantingrick" has published a small script on comp.lang.python that
should demonstrate the superiority of wxPython over Tkinter. That
somewhat backfired as several people who tried to run it on linux
encountered a segfault.

One report:
http://mail.python.org/pipermail/python-list/2011-January/1264579.html

The code in question:
https://sites.google.com/site/thefutureofpython/home/code-challenges

Is it a problem with the script, a wxPython bug, or a problem with the
platform? It would be nice if a wxPython expert could have a look at the
code.

My reply:
http://groups.google.com/group/comp.lang.python/msg/66c75d9d8f962aad

Thank you for looking into the matter.

Peter

lol on the “flameing troll” from robin’s response :smiley:

···


Hi, I will kill all ads in google gmail.
They will all be dead and gone for all my emails to you. HA HA bye bye ads I just massacred you!!!

yup -- and for making it clear that the "crash" was a result of how wxPython was built on that distro.

I notices elsewhere in that thread that someone using wxPython (who was generally positive about it), was reporting hard crashes fairly frequently.

I've been using wx for years, and hardly ever see a hard crash -- I guess that explains it! (I haven't used Linux much lately, either). If/when I go back to it, I'll make sure wx is compiled the way I want.

-Chris

···

On 1/24/11 11:48 PM, Peter Otten wrote:

Robin Dunn wrote:

My reply:
http://groups.google.com/group/comp.lang.python/msg/66c75d9d8f962aad

Thank you for looking into the matter.

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

That was probably me you are referring to. I get them every few weeks.
Not quite weekly, but I'm sure it's happened dozens of times in the
past 6 months. It seems like wxPython doesn't do a lot of argument
checking. If it requires a Window it assumes it gets a Window, etc. At
least it seems that way to me. I bet if you're an experienced wxPython
programmer you don't see them as often because you don't make freshman
or sophomore mistakes.

I don't remember precisely what last week's segfault was. It was
either me passing a sizer to a method when I should have passed a
panel (or visa versa) or I passed in a panel when I should have passed
in the parent of a panel. Those sorts of things seem to cause crashes
a lot.

I've still got it in my scrollback buffer, but of course there's no
traceback so I can't see what caused it, and too much time has
transpired to remember precisely what the solution was.

I find wxPython to be very powerful, but an exercise in frustration.
There's a whole lot to learn about wxPython that just doesn't seem to
be in any book or man page anywhere.

···

On Tue, Jan 25, 2011 at 11:32 AM, Christopher Barker <Chris.Barker@noaa.gov> wrote:

I notices elsewhere in that thread that someone using wxPython (who was
generally positive about it), was reporting hard crashes fairly frequently.

--
Bryan Oakley

That term seemed to cover all bases in this case. :wink:

···

On 1/25/11 4:59 AM, Micah Nordland wrote:

lol on the "flameing troll" from robin's response :smiley:

--
Robin Dunn
Software Craftsman

I notices elsewhere in that thread that someone using wxPython (who was
generally positive about it), was reporting hard crashes fairly frequently.

That was probably me you are referring to. I get them every few weeks.
Not quite weekly, but I'm sure it's happened dozens of times in the
past 6 months. It seems like wxPython doesn't do a lot of argument
checking. If it requires a Window it assumes it gets a Window, etc. At
least it seems that way to me.

wxPython does check parameter types as far as it is able to with the information given about what the the C++ function/method call is expecting. For example:

  >>> s = wx.BoxSizer()
  >>> w = wx.Frame(s)
  Traceback (most recent call last):
    File "<input>", line 1, in <module>
    File "/usr/local/lib/wxPython-2.9.1.1/lib/python2.6/site-packages/wx-2.9.1-osx_carbon/wx/_windows.py", line 575, in __init__
      _windows_.Frame_swiginit(self,_windows_.new_Frame(*args, **kwargs))
  TypeError: in method 'new_Frame', expected argument 1 of type 'wxWindow *'
  >>>

What it's not able to do as much of is to ensure that things are used correctly. wxWidgets does have a lot of assertion and similar statements that check for those kinds of things, but if you are on linux and are using wx packages from your distro provider then odds are that they have not turned on the runtime assertions when the wx libraries were built. You can check for sure by looking at wx.PlatformInfo. Here is the one from the Ubuntu packages:

  >>> import wx
  >>> wx.PlatformInfo
  ('__WXGTK__', 'wxGTK', 'unicode', 'gtk2', 'wx-assertions-off', 'SWIG-1.3.29')
  >>>

And here is one built in my current wxPython workspace:

  >>> import wx
  >>> wx.PlatformInfo
  ('__WXGTK__', 'wxGTK', 'unicode', 'gtk2', 'wx-assertions-on', 'SWIG-1.3.29')
  >>>

When the assertions are turned on then wxPython is able to catch them and raise them as Python exceptions that will usually help you figure out what you did wrong. Otherwise the wx code will usually just continue on doing the thing that the assertion would have warned is a bad thing to do, which can lead to a segfault. If you are using Linux as your primary development system then I strongly recommend that while in development and testing phases you either use the debug wx and wxPython packages if yoiur distro provides them, or build your own set of wxWidgets and wxPython binaries and adjust your PYTHONPATH and LD_LIBRARY_PATH to use that copy while in develop/test mode.

···

On 1/25/11 9:57 AM, Bryan Oakley wrote:

On Tue, Jan 25, 2011 at 11:32 AM, Christopher Barker > <Chris.Barker@noaa.gov> wrote:

--
Robin Dunn
Software Craftsman

I’ve had severe stability problems with window.Destroy(), especially in two contexts:

  1. Complex windows with a large number of controls, especially main frames

  2. The StaticBox - I used to create and remove these dynamically in response to button clicks (now I just use a very crude custom replacement)

For (2) at least, the crashing isn’t consistent - sometimes it happens, sometimes it doesn’t. I’ve mostly been using Macs for the basic development, so I’m not sure whether this applies to Linux too. The end result is that I don’t destroy most of my windows, and quitting the application requires a brute-force approach ending with process.kill(os.getpid()) if all else fails.

-Nat

···

On Tue, Jan 25, 2011 at 9:32 AM, Christopher Barker Chris.Barker@noaa.gov wrote:

I’ve been using wx for years, and hardly ever see a hard crash – I guess that explains it! (I haven’t used Linux much lately, either). If/when I go back to it, I’ll make sure wx is compiled the way I want.

What it's not able to do as much of is to ensure that things are used
correctly. wxWidgets does have a lot of assertion and similar statements
that check for those kinds of things, but if you are on linux and are using
wx packages from your distro provider then odds are that they have not
turned on the runtime assertions when the wx libraries were built. You can
check for sure by looking at wx.PlatformInfo. Here is the one from the
Ubuntu packages:

Yep, apparently I have "wx-assertions-off".

.... If you are using Linux as your primary development
system then I strongly recommend that while in development and testing
phases you either use the debug wx and wxPython packages if yoiur distro
provides them, or build your own set of wxWidgets and wxPython binaries and
adjust your PYTHONPATH and LD_LIBRARY_PATH to use that copy while in
develop/test mode.

That sounds like very good advice. Thanks!

···

On Tue, Jan 25, 2011 at 12:24 PM, Robin Dunn <robin@alldunn.com> wrote:

I have a 'bad' habit of writing a line of code into an app, then
launching the app, which would seem to help in terms of a seg fault.
My las t segfault involved the use of range to draw a line, and when
range was scaled to zero, it segfaulted. Making that range stop before
zero eliminated the segfault. So I'd think small increments in trial
and error tesing.

That's exactly what I do. I don't add very many lines at a time before
testing. I usually know what lines of code I added since the last
successful run. It's a pain. Turning on assertions, I think, will be
the smartest thing to do.

···

On Tue, Jan 25, 2011 at 12:44 PM, David Hutto <smokefloat@gmail.com> wrote:

I have a 'bad' habit of writing a line of code into an app, then
launching the app, which would seem to help in terms of a seg fault.
My las t segfault involved the use of range to draw a line, and when
range was scaled to zero, it segfaulted. Making that range stop before
zero eliminated the segfault. So I'd think small increments in trial
and error tesing.

It will make all the difference -- I'm not kidding that wx hasn't hard-crashed om me for ages. If it crashes with assertions turned on, then it's bug -- please report it. I'm sure there are still hard crashing bugs, but the stuff you refer to, just adding the wrong kind of object to to sizer, shouldn't hard crash.

Boy, I suspect that this strongly influences folks' impression of wxPython on Linux -- too bad. Python is a dynamic language, the compiler isn't going to check this stuff for you, you really need those assertions!

Robin -- is "Phoenix" going to handle this sort of thing differently/better? -- it seems maybe the wrappers should be doing more checking, rather than counting on C++ assertions.

-Chris

···

On 1/25/11 10:43 AM, Bryan Oakley wrote:

On Tue, Jan 25, 2011 at 12:24 PM, Robin Dunn<robin@alldunn.com> wrote:

Yep, apparently I have "wx-assertions-off".

.... If you are using Linux as your primary development
system then I strongly recommend that while in development and testing
phases you either use the debug wx and wxPython packages if yoiur distro
provides them, or build your own set of wxWidgets and wxPython binaries and
adjust your PYTHONPATH and LD_LIBRARY_PATH to use that copy while in
develop/test mode.

That sounds like very good advice. Thanks!

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

on ubuntu, what package are those assertions in?

···


Hi, I will kill all ads in google gmail.
They will all be dead and gone for all my emails to you. HA HA bye bye ads I just massacred you!!!