MayaVi installation on Qt4 leads to segmentation faults

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

MayaVi installation on Qt4 leads to segmentation faults

Uri Laserson
I am trying to install MayaVi on my computer. I'm on a MacBook Air with OS X
10.6.8, 4 GB RAM.

My python and most of my stack is built through Homebrew or pip. In
particular this is true for python2.7, ipython, Qt4, numpy, scipy, vtk, etc.
VTK was installed with --python and --qt-extern flags in Homebrew, and all
the builds were fine. I do not have wxPython installed, as I failed to get
it working through pip, manual building, or the binaries.

If I run ipython -q4thread, I cannot successfully execute from mayavi import
mlab as I get an error related to usage of two different APIs for PyQt:
http://groups.google.com/group/spyderlib/browse_thread/thread/36a35baec74ca144

However, if I run ipython alone, I can successfully run from mayavi import
mlab. Then I try to follow this example:
http://github.enthought.com/mayavi/mayavi/example_using_with_scipy.html,
which includes these commands:

    import numpy as np

    def V(x, y, z):
        """ A 3D sinusoidal lattice with a parabolic confinement. """
        return np.cos(10*x) + np.cos(10*y) + np.cos(10*z) + 2*(x**2 + y**2 +
z**2)

    X, Y, Z = np.mgrid[-2:2:100j, -2:2:100j, -2:2:100j]

    from mayavi import mlab
    mlab.contour3d(X, Y, Z, V)

This all works fine, and I get a window that pops up and I can rotate the 3d
plot etc. However, then I click on the icon to open up the pipeline, which
opens another window. The tutorial then says to double-click on the
"isosurface" to change its properties. As soon as I do that, I get a
reproducible segmentation fault.

I have no idea how to begin to figure out what the problem is.

Alternatively, I can run MayaVi from the command line: mayavi2, and the GUI
pops up. When I do so I get the following output:

    Warning: Unable to import the wx backend for pyface due to traceback:
Traceback (most recent call last):
          File
"/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/pyface/toolkit.py",
line 45, in _init_toolkit
            be = import_toolkit(tk)
          File
"/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/pyface/toolkit.py",
line 31, in import_toolkit
            __import__(be + 'init')
          File
"/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/pyface/ui/wx/init.py",
line 14, in <module>
            import wx
        ImportError: No module named wx

Although the GUI does pop up, if I try to do any operation, I get a
segfault.

Please let me know if you have any thoughts on troubleshooting this, or
perhaps guidance on reinstalling the package successfully.

Thanks!
Uri

............................................................................
Uri Laserson
Graduate Student, Biomedical Engineering, Church Lab
Harvard-MIT Division of Health Sciences and Technology
M +1 617 910 0447
[hidden email]
http://web.mit.edu/laserson/www/
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: MayaVi installation on Qt4 leads to segmentation faults

Gael Varoquaux
On Mon, Oct 10, 2011 at 09:14:32PM -0400, Uri Laserson wrote:
> If I run ipython -q4thread, I cannot successfully execute from mayavi import
> mlab as I get an error related to usage of two different APIs for PyQt:
> http://groups.google.com/group/spyderlib/browse_thread/thread/36a35baec74ca144

Hum, I am not the expert here. Do people on the mailing list have
opinions or advice?

> This all works fine, and I get a window that pops up and I can rotate the 3d
> plot etc. However, then I click on the icon to open up the pipeline, which
> opens another window. The tutorial then says to double-click on the
> "isosurface" to change its properties. As soon as I do that, I get a
> reproducible segmentation fault.

Could you run this through gdb, as detailed in
http://scipy-lectures.github.com/advanced/debugging/index.html#debugging-segmentation-faults-using-gdb

This would help us figure out what is going on.

Cheers,

Gaël
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: MayaVi installation on Qt4 leads to segmentation faults

Phil Thompson
On Tue, 11 Oct 2011 07:15:42 +0200, Gael Varoquaux
<[hidden email]> wrote:
> On Mon, Oct 10, 2011 at 09:14:32PM -0400, Uri Laserson wrote:
>> If I run ipython -q4thread, I cannot successfully execute from mayavi
>> import
>> mlab as I get an error related to usage of two different APIs for PyQt:
>>
http://groups.google.com/group/spyderlib/browse_thread/thread/36a35baec74ca144
>
> Hum, I am not the expert here. Do people on the mailing list have
> opinions or advice?

I've explained this before but it apparently continues to fall on deaf
ears.

>> This all works fine, and I get a window that pops up and I can rotate
>> the 3d
>> plot etc. However, then I click on the icon to open up the pipeline,
>> which
>> opens another window. The tutorial then says to double-click on the
>> "isosurface" to change its properties. As soon as I do that, I get a
>> reproducible segmentation fault.
>
> Could you run this through gdb, as detailed in
>
http://scipy-lectures.github.com/advanced/debugging/index.html#debugging-segmentation-faults-using-gdb
>
> This would help us figure out what is going on.

ETS is explicitly setting the API - this is a bug. It requires all other
PyQt code (your own application and any 3rd party packages, ipython in this
case) to use the same API. When the API being set is not the default (as in
this case) then things are bound to break.

Phil
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: MayaVi installation on Qt4 leads to segmentation faults

Jonathan Blakes
In reply to this post by Uri Laserson
(My thoughts on the Qt API issue below.)

On 11/10/11 09:49, [hidden email] wrote:
> I've explained this before but it apparently continues to fall on deaf
> ears.
>

<snip/>

> ETS is explicitly setting the API - this is a bug. It requires all other
> PyQt code (your own application and any 3rd party packages, ipython
in this
> case) to use the same API. When the API being set is not the default
(as in
> this case) then things are bound to break.
>
> Phil
>

This has also caused me major headaches.

Our PyQt/Traits-based, Mayavi-using software is available for all
platforms: for Ubuntu/Debian we need to depend on older traits packages
(that use version 1 of the QString and QVariant APIs) as the latest
versions of traits are not being backported to previous releases (Ubuntu
is slower than Debian in this respect).

Consequently, when freezing for Windows and Mac we must use older
versions (6.3) of EPD so the code works on all platforms, and these
harbour bugs in packages like Matplotlib and PyTables that have been
fixed in later versions, but which we cannot take advantage of. (Aside,
  only EPD 7 seems to be available for download - is there an archive of
old EPDs?)

I understand that supporting both APIs would involve maintaining 2
versions of the all the TraitsBackendQt classes, or wrapping all
potential QStrings/QVariants in functions that return the appropriate Qt
or Python types ...

import sip
if sip.getapi('QString') == 1:
     from PyQt4.QtCore import QString

def qstring(qs):
     '''Wrap potential QStrings'''
     if sip.getapi('QString') == 1:
         return QString(qs)
     else:
         return unicode(qs)

def eg():
     return qstring("I might be a QString or I might be a unicode");

But, I believe it makes more sense to do this at the ETS level, rather
than every developer in my position coming up with a half-baked solution
like above.

Now that PySide has been dropped by Nokia doesn't it make sense to
support the PyQt ecosystem even more.

Jon

--
Jonathan Blakes
Room B82
School of Computer Science
University of Nottingham
Jubilee Campus
Wollaton Road
Nottingham, NG8 1BB
United Kingdom
+44 115 84 68403
[hidden email]
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: MayaVi installation on Qt4 leads to segmentation faults

Uri Laserson
So I ran the following script through gdb:

<python>
import numpy as np

def V(x, y, z):
    """ A 3D sinusoidal lattice with a parabolic confinement. """
    return np.cos(10*x) + np.cos(10*y) + np.cos(10*z) + 2*(x**2 + y**2 +
z**2)

X, Y, Z = np.mgrid[-2:2:100j, -2:2:100j, -2:2:100j]

from mayavi import mlab
mlab.contour3d(X, Y, Z, V)

raw_input('hello...')
</python>

I then induce the segfault through the GUI, which gives me:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000010
0x0000000103ec955c in sip_api_is_py_method ()


Then I print the backtrace:
#0  0x0000000103ec955c in sip_api_is_py_method ()
#1  0x00000001040fd309 in sipQObject::eventFilter ()
#2  0x00000001043d8a87 in
QCoreApplicationPrivate::sendThroughObjectEventFilters ()
#3  0x0000000105b5fcae in QApplicationPrivate::notify_helper ()
#4  0x0000000105b66614 in QApplication::notify ()
#5  0x0000000105536b5e in sipQApplication::notify ()
#6  0x00000001042fe58c in QCoreApplication::notifyInternal ()
#7  0x00000001043d9566 in QCoreApplicationPrivate::sendPostedEvents ()
#8  0x00007fff83f9c401 in __CFRunLoopDoSources0 ()
#9  0x00007fff83f9a5f9 in __CFRunLoopRun ()
#10 0x00007fff83f99dbf in CFRunLoopRunSpecific ()
#11 0x00007fff854fd7ee in RunCurrentEventLoopInMode ()
#12 0x00007fff854fd551 in ReceiveNextEventCommon ()
#13 0x00007fff854fd4ac in BlockUntilNextEventMatchingListInMode ()
#14 0x00007fff890aeeb2 in _DPSNextEvent ()
#15 0x00007fff890ae801 in -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#16 0x00007fff8907468f in -[NSApplication run] ()
#17 0x0000000105b1b9b5 in QEventDispatcherMac::processEvents ()
#18 0x00000001043d8134 in QEventLoop::processEvents ()
#19 0x00000001043d8454 in QEventLoop::exec ()
#20 0x00000001043d980a in QCoreApplication::exec ()
#21 0x00000001040092e3 in qtcore_input_hook ()
#22 0x00000001000088fa in my_fgets ()
#23 0x00000001000089ee in PyOS_StdioReadline ()
#24 0x0000000100008c00 in PyOS_Readline ()
#25 0x00000001000ba575 in builtin_raw_input ()
#26 0x00000001000c55ed in PyEval_EvalFrameEx ()
#27 0x00000001000c79b6 in PyEval_EvalCodeEx ()
#28 0x00000001000c7ad6 in PyEval_EvalCode ()
#29 0x00000001000ecbae in PyRun_FileExFlags ()
#30 0x00000001000ece69 in PyRun_SimpleFileExFlags ()
#31 0x000000010010364c in Py_Main ()
#32 0x0000000100000e22 in _start ()
#33 0x0000000100000d41 in start ()

Unfortunately, I set my .gdbinit file as described in the Gael's referenced
link, but when I try to execute pyframe, I get:
No symbol "PyStringObject" in current context.

In fact, whenever I go up the stack, I never get any information about what
source line I'm in.

And the lineno command defined in the gdbinit file gives me:
Attempt to extract a component of a value that is not a structure pointer

Thanks!
Uri

............................................................................
Uri Laserson
Graduate Student, Biomedical Engineering, Church Lab
Harvard-MIT Division of Health Sciences and Technology
M +1 617 910 0447
[hidden email]
http://web.mit.edu/laserson/www/




On Wed, Oct 12, 2011 at 04:53, Jonathan Blakes <[hidden email]> wrote:

> (My thoughts on the Qt API issue below.)
>
> On 11/10/11 09:49, [hidden email] wrote:
> > I've explained this before but it apparently continues to fall on deaf
> > ears.
> >
>
> <snip/>
>
> > ETS is explicitly setting the API - this is a bug. It requires all other
> > PyQt code (your own application and any 3rd party packages, ipython
> in this
> > case) to use the same API. When the API being set is not the default
> (as in
> > this case) then things are bound to break.
> >
> > Phil
> >
>
> This has also caused me major headaches.
>
> Our PyQt/Traits-based, Mayavi-using software is available for all
> platforms: for Ubuntu/Debian we need to depend on older traits packages
> (that use version 1 of the QString and QVariant APIs) as the latest
> versions of traits are not being backported to previous releases (Ubuntu
> is slower than Debian in this respect).
>
> Consequently, when freezing for Windows and Mac we must use older
> versions (6.3) of EPD so the code works on all platforms, and these
> harbour bugs in packages like Matplotlib and PyTables that have been
> fixed in later versions, but which we cannot take advantage of. (Aside,
>  only EPD 7 seems to be available for download - is there an archive of
> old EPDs?)
>
> I understand that supporting both APIs would involve maintaining 2
> versions of the all the TraitsBackendQt classes, or wrapping all
> potential QStrings/QVariants in functions that return the appropriate Qt
> or Python types ...
>
> import sip
> if sip.getapi('QString') == 1:
>     from PyQt4.QtCore import QString
>
> def qstring(qs):
>     '''Wrap potential QStrings'''
>     if sip.getapi('QString') == 1:
>         return QString(qs)
>     else:
>         return unicode(qs)
>
> def eg():
>     return qstring("I might be a QString or I might be a unicode");
>
> But, I believe it makes more sense to do this at the ETS level, rather
> than every developer in my position coming up with a half-baked solution
> like above.
>
> Now that PySide has been dropped by Nokia doesn't it make sense to
> support the PyQt ecosystem even more.
>
> Jon
>
> --
> Jonathan Blakes
> Room B82
> School of Computer Science
> University of Nottingham
> Jubilee Campus
> Wollaton Road
> Nottingham, NG8 1BB
> United Kingdom
> +44 115 84 68403
> [hidden email]
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
>
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: MayaVi installation on Qt4 leads to segmentation faults

Gael Varoquaux
On Wed, Oct 12, 2011 at 02:53:37PM -0400, Uri Laserson wrote:
> So I ran the following script through gdb:

> [snip]

So the traceback is most probably related to Qt code.

> Program received signal EXC_BAD_ACCESS, Could not access memory.
> Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000010
           ^
Robert, will you please stay out of people's computer.

> Unfortunately, I set my .gdbinit file as described in the Gael's referenced
> link, but when I try to execute pyframe, I get:
> No symbol "PyStringObject" in current context.

It should have worked in one of the following stack frames:

> #26 0x00000001000c55ed in PyEval_EvalFrameEx ()
> #27 0x00000001000c79b6 in PyEval_EvalCodeEx ()
> #28 0x00000001000c7ad6 in PyEval_EvalCode ()

> In fact, whenever I go up the stack, I never get any information about what
> source line I'm in.

OK. Maybe we can fix that. It would make it much easier to diagnose the
segfault. Please remind me under which OS you are.

Cheers,

Gaël
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: MayaVi installation on Qt4 leads to segmentation faults

Uri Laserson
>
> > Unfortunately, I set my .gdbinit file as described in the Gael's
> referenced
> > link, but when I try to execute pyframe, I get:
> > No symbol "PyStringObject" in current context.
>
>
So perhaps you should also know that when I run `gdb python`, I get a bunch
of warnings like:
warning: Could not find object file
"/private/tmp/homebrew-python-2.7.1-sHAz/Python-2.7.1/Modules/python.o" - no
debug information available for "./Modules/python.c"



> It should have worked in one of the following stack frames:
>
> > #26 0x00000001000c55ed in PyEval_EvalFrameEx ()
> > #27 0x00000001000c79b6 in PyEval_EvalCodeEx ()
> > #28 0x00000001000c7ad6 in PyEval_EvalCode ()
>

I always get that same error.  Perhaps my python is not compiled properly to
allow debugging?


> Please remind me under which OS you are.
>

OS X 10.6, with homebrew-ed packages.  Using python2.7.

Thanks!
Uri
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: MayaVi installation on Qt4 leads to segmentation faults

Gael Varoquaux
On Wed, Oct 12, 2011 at 05:16:52PM -0400, Uri Laserson wrote:
> > Please remind me under which OS you are.

> OS X 10.6, with homebrew-ed packages.  Using python2.7.

Arg. I am pretty clueless under OS X. I can't really help much with gdb
here.

G
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev