Bus error using interactive plotting commands

I recently updated matplotlib, and I am now getting a bus error when plotting (any command) after I have already closed a matplotlib window. I can open as many windows as I want, but the first plot command executed after closing any window results in a bus error.

Relavent things:

OS: Mac OS X
Backend: TkAgg (same bus error with qt4, though)
very recent svn versions of numpy/mpl/ipython.

I hadn't updated in a while (weeks) prior to the last update, so I am not exactly sure when the bug appeared.

-Rob

···

----
Rob Hetland, Associate Professor
Dept. of Oceanography, Texas A&M University
http://pong.tamu.edu/~rob
phone: 979-458-0096, fax: 979-845-6331

The fact that you get this with Tk makes me suspect that for once,
it's not ipython's fault (since Tk does NOT activate the more
dangerous threading tricks). But it would be good to be 100% sure, by
trying in a pure python terminal

from pylab import *
ion()
plot(...)

and see if the crash persists. That would limit the likely culprits
to two out of three (and move this ball out of my court in the process
:slight_smile:

cheers,

f

···

On 7/12/07, Rob Hetland <hetland@...345...> wrote:

I recently updated matplotlib, and I am now getting a bus error when
plotting (any command) after I have already closed a matplotlib
window. I can open as many windows as I want, but the first plot
command executed after closing any window results in a bus error.

Relavent things:

OS: Mac OS X
Backend: TkAgg (same bus error with qt4, though)
very recent svn versions of numpy/mpl/ipython.

Nope -- the same occurs in the regular terminal, so it's not iPython's fault.

Also, although I though I remembered this happening with qt4 (as posted below), I do not seem to be able to reproduce this now..

Also, clearing and closing the figure works fine -- only clicking it away triggers the bug.

So: Almost surely MPL, probably Tk, is my guess.

-Rob

···

On Jul 13, 2007, at 1:34 AM, Fernando Perez wrote:

On 7/12/07, Rob Hetland <hetland@...345...> wrote:

I recently updated matplotlib, and I am now getting a bus error when
plotting (any command) after I have already closed a matplotlib
window. I can open as many windows as I want, but the first plot
command executed after closing any window results in a bus error.

Relavent things:

OS: Mac OS X
Backend: TkAgg (same bus error with qt4, though)
very recent svn versions of numpy/mpl/ipython.

The fact that you get this with Tk makes me suspect that for once,
it's not ipython's fault (since Tk does NOT activate the more
dangerous threading tricks). But it would be good to be 100% sure, by
trying in a pure python terminal

from pylab import *
ion()
plot(...)

and see if the crash persists. That would limit the likely culprits
to two out of three (and move this ball out of my court in the process
:slight_smile:

cheers,

f

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options

----
Rob Hetland, Associate Professor
Dept. of Oceanography, Texas A&M University
http://pong.tamu.edu/~rob
phone: 979-458-0096, fax: 979-845-6331

Included below are our standard segfault instructions. The first
thing to do is to make sure you blow away your build dir and installed
mpl and get a clean build. Secondly, make sure you are using numpy
and your rc numerix setting is numpy. Here are the instructions::

# How to diagnose where a segfault is occurring

First thing to try is simply rm -rf the site-packages/matplotlib and
build subdirs and get a clean install. Installing a new version over
a pretty old version has been known to cause trouble, segfault, etc.

Try importing these packages individually

  import matplotlib._image
  import matplotlib._transforms

  #one of these three depending on which numerix package you are using
  import matplotlib.backends._na_backend_agg # for numarray
  import matplotlib.backends._nc_backend_agg # for Numeric
  import matplotlib.backends._ns_backend_agg # for numpy

  import matplotlib.backends._tkagg
  import matplotlib._agg

If the last two work and the others don't, it is likely you need to
upgrade your gcc, because on some platforms (OS X for sure) old
versions of gcc cannot compile new versions of pycxx, which matplotlib
uses for building some but not all of it's extensions. Report back
which if any work or segfault or raise tracebacks,

If that shed additional light, again flush the build and install dirs,
and try setting VERBOSE=True in setup.py before doing a clean install.
The VERBOSE setting will generate lots of extra output and may help
indicate where the segfault is occurring

···

On 7/13/07, Rob Hetland <hetland@...345...> wrote:

Nope -- the same occurs in the regular terminal, so it's not
iPython's fault.

Also, although I though I remembered this happening with qt4 (as
posted below), I do not seem to be able to reproduce this now..

Also, clearing and closing the figure works fine -- only clicking it
away triggers the bug.
So: Almost surely MPL, probably Tk, is my guess.

FWIW, I'm able to reproduce this here. I have a hunch it may be related to my recent Tk memory leak "improvements". I'll look into this further and get back soon.

Cheers,
Mike

John Hunter wrote:

···

On 7/13/07, Rob Hetland <hetland@...345...> wrote:
  

Nope -- the same occurs in the regular terminal, so it's not
iPython's fault.

Also, although I though I remembered this happening with qt4 (as
posted below), I do not seem to be able to reproduce this now..

Also, clearing and closing the figure works fine -- only clicking it
away triggers the bug.
So: Almost surely MPL, probably Tk, is my guess.
    
Included below are our standard segfault instructions. The first
thing to do is to make sure you blow away your build dir and installed
mpl and get a clean build. Secondly, make sure you are using numpy
and your rc numerix setting is numpy. Here are the instructions::

# How to diagnose where a segfault is occurring

First thing to try is simply rm -rf the site-packages/matplotlib and
build subdirs and get a clean install. Installing a new version over
a pretty old version has been known to cause trouble, segfault, etc.

Try importing these packages individually

  import matplotlib._image
  import matplotlib._transforms

  #one of these three depending on which numerix package you are using
  import matplotlib.backends._na_backend_agg # for numarray
  import matplotlib.backends._nc_backend_agg # for Numeric
  import matplotlib.backends._ns_backend_agg # for numpy

  import matplotlib.backends._tkagg
  import matplotlib._agg

If the last two work and the others don't, it is likely you need to
upgrade your gcc, because on some platforms (OS X for sure) old
versions of gcc cannot compile new versions of pycxx, which matplotlib
uses for building some but not all of it's extensions. Report back
which if any work or segfault or raise tracebacks,

If that shed additional light, again flush the build and install dirs,
and try setting VERBOSE=True in setup.py before doing a clean install.
The VERBOSE setting will generate lots of extra output and may help
indicate where the segfault is occurring

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options

Try importing these packages individually

import matplotlib._image
import matplotlib._transforms

#one of these three depending on which numerix package you are using
import matplotlib.backends._na_backend_agg # for numarray
import matplotlib.backends._nc_backend_agg # for Numeric
import matplotlib.backends._ns_backend_agg # for numpy

import matplotlib.backends._tkagg
import matplotlib._agg

I have done all the usual tricks (wipe build, get newest numpy/mpl, etc).

I tried the suggestions above, and get an error for only one:

>>> import matplotlib.backends._tkagg
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/backends/_tkagg.so, 2): Symbol not found: _Tcl_AppendResult
   Referenced from: /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/backends/_tkagg.so
   Expected in: dynamic lookup

I think this is strange, because Tk works fine when I don't click-close a Tk window -- I.e., no errors when pylab starts, or plots, etc.

-Rob

···

On Jul 13, 2007, at 9:14 AM, John Hunter wrote:

----
Rob Hetland, Associate Professor
Dept. of Oceanography, Texas A&M University
http://pong.tamu.edu/~rob
phone: 979-458-0096, fax: 979-845-6331

This looks like that was introduced by a patching error when fixing the Tk save figure bug recently. The bug tracker added an extraneous newline to my patch submitted as a comment. (That's the last time I do that :wink:

http://sourceforge.net/tracker/index.php?func=detail&aid=1716732&group_id=80706&atid=560720

The segfault was happening because it was trying to blit to a window that had been destroyed (and the figure manager wasn't creating a new window as it should have.)

I've committed a fix on the Python end, and also a check to the C side (_tkagg.cpp), so that if we get ourselves into that situation again, we'll get a Python exception rather than a segfault.

If you still see crashes with the Qt backend, also let us know. This fix doesn't affect Qt at all.

Cheers,
Mike

Michael Droettboom wrote:

···

FWIW, I'm able to reproduce this here. I have a hunch it may be related to my recent Tk memory leak "improvements". I'll look into this further and get back soon.

Cheers,
Mike

John Hunter wrote:
  

On 7/13/07, Rob Hetland <hetland@...345...> wrote:
  

Nope -- the same occurs in the regular terminal, so it's not
iPython's fault.

Also, although I though I remembered this happening with qt4 (as
posted below), I do not seem to be able to reproduce this now..

Also, clearing and closing the figure works fine -- only clicking it
away triggers the bug.
So: Almost surely MPL, probably Tk, is my guess.
    

Included below are our standard segfault instructions. The first
thing to do is to make sure you blow away your build dir and installed
mpl and get a clean build. Secondly, make sure you are using numpy
and your rc numerix setting is numpy. Here are the instructions::

# How to diagnose where a segfault is occurring

First thing to try is simply rm -rf the site-packages/matplotlib and
build subdirs and get a clean install. Installing a new version over
a pretty old version has been known to cause trouble, segfault, etc.

Try importing these packages individually

  import matplotlib._image
  import matplotlib._transforms

  #one of these three depending on which numerix package you are using
  import matplotlib.backends._na_backend_agg # for numarray
  import matplotlib.backends._nc_backend_agg # for Numeric
  import matplotlib.backends._ns_backend_agg # for numpy

  import matplotlib.backends._tkagg
  import matplotlib._agg

If the last two work and the others don't, it is likely you need to
upgrade your gcc, because on some platforms (OS X for sure) old
versions of gcc cannot compile new versions of pycxx, which matplotlib
uses for building some but not all of it's extensions. Report back
which if any work or segfault or raise tracebacks,

If that shed additional light, again flush the build and install dirs,
and try setting VERBOSE=True in setup.py before doing a clean install.
The VERBOSE setting will generate lots of extra output and may help
indicate where the segfault is occurring

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options
  
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options

First of all, Qt4 does appear to work fine.

Second. I am trying to recompile, and I get the error attached below. Somebody had mentioned needing a recent version of gcc. Is this the problem here, or is it another bug?

-Rob

gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3 -Isrc -I. -I/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/numpy/core/include -I/usr/local/include -I/usr/include -I. -I/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c src/transforms.cpp -o build/temp.macosx-10.3-fat-2.5/src/transforms.o
src/transforms.cpp: In member function ‘Py::Object Bbox::update(const Py::Tuple&)’:
src/transforms.cpp:478: error: ‘isnan’ was not declared in this scope
src/transforms.cpp: In member function ‘Py::Object Bbox::update(const Py::Tuple&)’:
src/transforms.cpp:478: error: ‘isnan’ was not declared in this scope
src/transforms.cpp: In member function ‘Py::Object Bbox::update_numerix_xy(const Py::Tuple&)’:
src/transforms.cpp:542: error: ‘isnan’ was not declared in this scopesrc/transforms.cpp: In member function ‘Py::Object Bbox::update_numerix_xy(const Py::Tuple&)’:
src/transforms.cpp:542: error: ‘isnan’ was not declared in this scope

src/transforms.cpp: In member function ‘Py::Object Bbox::update_numerix(const Py::Tuple&)’:
src/transforms.cpp:616: error: ‘isnan’ was not declared in this scope
src/transforms.cpp: In member function ‘Py::Object Bbox::update_numerix(const Py::Tuple&)’:
src/transforms.cpp:616: error: ‘isnan’ was not declared in this scope
src/transforms.cpp: In member function ‘Py::Object Transformation::nonlinear_only_numerix(const Py::Tuple&, const Py::Dict&)’:
src/transforms.cpp:1258: error: ‘isnan’ was not declared in this scope
src/transforms.cpp: In member function ‘Py::Object Transformation::nonlinear_only_numerix(const Py::Tuple&, const Py::Dict&)’:
src/transforms.cpp:1258: error: ‘isnan’ was not declared in this scope
lipo: can't figure out the architecture type of: /var/tmp//ccVkIyQR.out
error: command 'gcc' failed with exit status 1

···

----
Rob Hetland, Associate Professor
Dept. of Oceanography, Texas A&M University
http://pong.tamu.edu/~rob
phone: 979-458-0096, fax: 979-845-6331

grr. that's probably my fault. I just fiddled with the definition of
npy. I tested this on linux and thought I copied it pretty directly from
numpy, so I assumed it would work elsewhere, but it's not. I'll see what
I can do...

Rob Hetland wrote:

···

First of all, Qt4 does appear to work fine.

Second. I am trying to recompile, and I get the error attached
below. Somebody had mentioned needing a recent version of gcc. Is
this the problem here, or is it another bug?

-Rob

gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -
fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -
fno-common -dynamic -DNDEBUG -g -O3 -Isrc -I. -I/Library/Frameworks/
Python.framework/Versions/2.5/lib/python2.5/site-packages/numpy/core/
include -I/usr/local/include -I/usr/include -I. -I/Library/Frameworks/
Python.framework/Versions/2.5/include/python2.5 -c src/transforms.cpp
-o build/temp.macosx-10.3-fat-2.5/src/transforms.o
src/transforms.cpp: In member function �Py::Object Bbox::update(const
Py::Tuple&)�:
src/transforms.cpp:478: error: �isnan� was not declared in this scope
src/transforms.cpp: In member function �Py::Object Bbox::update(const
Py::Tuple&)�:
src/transforms.cpp:478: error: �isnan� was not declared in this scope
src/transforms.cpp: In member function �Py::Object
Bbox::update_numerix_xy(const Py::Tuple&)�:
src/transforms.cpp:542: error: �isnan� was not declared in this
scopesrc/transforms.cpp: In member function �Py::Object
Bbox::update_numerix_xy(const Py::Tuple&)�:
src/transforms.cpp:542: error: �isnan� was not declared in this scope

src/transforms.cpp: In member function �Py::Object
Bbox::update_numerix(const Py::Tuple&)�:
src/transforms.cpp:616: error: �isnan� was not declared in this scope
src/transforms.cpp: In member function �Py::Object
Bbox::update_numerix(const Py::Tuple&)�:
src/transforms.cpp:616: error: �isnan� was not declared in this scope
src/transforms.cpp: In member function �Py::Object
Transformation::nonlinear_only_numerix(const Py::Tuple&, const
Py::Dict&)�:
src/transforms.cpp:1258: error: �isnan� was not declared in this scope
src/transforms.cpp: In member function �Py::Object
Transformation::nonlinear_only_numerix(const Py::Tuple&, const
Py::Dict&)�:
src/transforms.cpp:1258: error: �isnan� was not declared in this scope
lipo: can't figure out the architecture type of: /var/tmp//ccVkIyQR.out
error: command 'gcc' failed with exit status 1

----
Rob Hetland, Associate Professor
Dept. of Oceanography, Texas A&M University
http://pong.tamu.edu/~rob
phone: 979-458-0096, fax: 979-845-6331

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options

It amy also be that he got a revision in an inconsistent state. At
one point I committed some broken isnan stuff I was testing, so make
sure you have the latest svn and try again.

JDH

···

On 7/13/07, Andrew Straw <strawman@...36...> wrote:

grr. that's probably my fault. I just fiddled with the definition of
npy. I tested this on linux and thought I copied it pretty directly from
numpy, so I assumed it would work elsewhere, but it's not. I'll see what
I can do...

John Hunter wrote:

grr. that's probably my fault. I just fiddled with the definition of
npy. I tested this on linux and thought I copied it pretty directly from
numpy, so I assumed it would work elsewhere, but it's not. I'll see what
I can do...

It amy also be that he got a revision in an inconsistent state. At
one point I committed some broken isnan stuff I was testing, so make
sure you have the latest svn and try again.

No, it looks like I screwed up - the top of numpy's umathmodule.c.src
has a lot of stuff that would be really nice if numpy made available in
a header file. This stuff is not necessary with my default compiler
settings on my linux workstation, but on Mac OS X (and surely other
platforms) it is. So, I've just reverted to our old way.

I'll see if I can add isfinite() and also re-implement a couple cleanups
I just took out after putting them in this morning.

Rob, you should be able to compile now as of r3515.

···

On 7/13/07, Andrew Straw <strawman@...36...> wrote:

It seems to be working now. Thanks!

This is a perfect example of quick response. I keep telling people that, sure, the scientific python suite has occasional bugs, but the community is *very* responsive. This is a perfect example. Thanks to everybody that helped,

-Rob

···

Rob, you should be able to compile now as of r3515.

----
Rob Hetland, Associate Professor
Dept. of Oceanography, Texas A&M University
http://pong.tamu.edu/~rob
phone: 979-458-0096, fax: 979-845-6331