PyPlot.jl icon indicating copy to clipboard operation
PyPlot.jl copied to clipboard

Segfault with qt >=4.8.6 on ubuntu

Open swt30 opened this issue 8 years ago • 46 comments

I updated my (systemwide) miniconda installation but now PyPlot is in trouble:

julia> using PyPlot

julia> plot(1:10, randn(10))

signal(11): Segmentation fault
unknown function (ip: 0x32736)
unknown function (ip: (nil))
[1]    4493 segmentation fault: julia

The issue remains with a fresh installation of PyPlot and ENV["PYTHON"] = "" to ensure that a fresh download of Conda.jl is used instead. But everything is fine if I plot from Python directly. I'm using julia 0.4.6 on Linux x86_64 (ubuntu 16.04).

Anything I can do to diagnose this further?

swt30 avatar Jul 27 '16 17:07 swt30

Can you try Pkg.checkout("PyCall"); Pkg.build("PyCall") to see if the problem persists with PyCall master?

stevengj avatar Jul 27 '16 18:07 stevengj

Or actually maybe you just need to re-run Pkg.build("PyCall").

stevengj avatar Jul 27 '16 18:07 stevengj

Problem still persists - here's a backtrace.

swt30 avatar Jul 27 '16 18:07 swt30

OK, downgrading python/qt/sip works:

$ conda install python=3.4 pyqt=4.10

[...]

The following packages will be DOWNGRADED due to dependency conflicts:

    pyqt:            4.11.4-py35_4     --> 4.10.4-py34_0    
    python:          3.5.2-0           --> 3.4.5-0          
    qt:              4.8.7-4           --> 4.8.5-0          
    sip:             4.18-py35_0       --> 4.15.5-py34_0    

The problem therefore appeared somewhere in these updates.

swt30 avatar Jul 27 '16 20:07 swt30

Are you using the same backend (qt) in Julia and when you call Matplotlib directly from Conda's Python?

stevengj avatar Jul 27 '16 21:07 stevengj

Yes I am.

julia> using PyPlot

julia> pygui(:qt)
:qt

julia> figure()

signal (11): Segmentation fault
unknown function (ip: 0x32736)
unknown function (ip: (nil))
[1]    27445 segmentation fault  julia
~❯ ipython
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul  2 2016, 17:53:06) 
Type "copyright", "credits" or "license" for more information.

IPython 5.0.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: %pylab qt
Populating the interactive namespace from numpy and matplotlib

In [2]: figure()
Out[2]: <matplotlib.figure.Figure at 0x7f06a03d4940>

That's again using a system miniconda install, but same thing if I let Conda do it.

swt30 avatar Jul 27 '16 22:07 swt30

What happens if you use a different backend, e.g. tk?

stevengj avatar Jul 27 '16 22:07 stevengj

Works fine:

julia> using PyCall

julia> pygui(:tk)
:tk

julia> using PyPlot

julia> figure()
PyPlot.Figure(PyObject <matplotlib.figure.Figure object at 0x7f9a9baf2780>)

swt30 avatar Jul 28 '16 11:07 swt30

That's helpful, so it is something about the way we are calling Qt (presumably the event loop in PyCall/src/gui.jl) that doesn't work any more...

What happens if you just start the Qt event loop? using PyCall; pygui_start(:qt).

stevengj avatar Jul 28 '16 12:07 stevengj

That also works just fine.

swt30 avatar Jul 28 '16 12:07 swt30

Does Conda with Python2 work?

stevengj avatar Jul 28 '16 14:07 stevengj

No. When I tested it with Conda.jl, which uses Python 2, it didn't work with the newer Qt either.

If anyone reading this needs a temporary workaround, you should be able to do Conda.add("qt=4.8.5") to downgrade your version of qt.

swt30 avatar Jul 28 '16 14:07 swt30

Just tried it on MacOS and PyPlot is working fine with Conda and pyqt-4.11.4, so it may be something specific to Linux.

stevengj avatar Jul 28 '16 14:07 stevengj

I've been able to run it successfully on a different Linux box, so it's only specific to my machine at the moment :/

swt30 avatar Jul 28 '16 15:07 swt30

Ah, maybe its a conflict in your library paths somehow? Maybe you have multiple libqt libraries installed and the system is getting confused about which one to load or something?

stevengj avatar Jul 28 '16 15:07 stevengj

I don't believe I have any other libqt libraries installed. The only place seems to be in the conda directory. I've confirmed that the crash is related to the version of qt in the conda environment: it happens for version 4.8.6 and above.

swt30 avatar Jul 28 '16 16:07 swt30

This happens to me as well, but it dissapears by running julia with root permission. Hope this helps:

signal (11): Segmentation fault
unknown function (ip: 0x32736)
[1]    14234 segmentation fault (core dumped)  julia

lopezm94 avatar Jul 31 '16 10:07 lopezm94

Huh - yes I can confirm that running julia as root also gets around this.

swt30 avatar Jul 31 '16 15:07 swt30

Would be nice to have a fix for this though, Plots.jl has this as a dependency

lopezm94 avatar Aug 01 '16 13:08 lopezm94

Plots.jl has this as a dependency

No it doesn't

tbreloff avatar Aug 01 '16 14:08 tbreloff

Sorry, I meant uses it as default backend.

lopezm94 avatar Aug 01 '16 14:08 lopezm94

Just for the record, I have this exact same issue. This crashes (normal Conda.jl install):

using PyPlot
plot(rand(10))

This works:

using PyCall
pygui(:tk)
using PyPlot
plot(rand(10))

and this works as well:

import Conda
Conda.add("qt=4.8.5")
using PyPlot
plot(rand(10))

I'm on Ubuntu:

   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.0-rc0+111 (2016-08-01 19:26 UTC)
 _/ |\__'_|_|_|\__'_|  |  tb_pkgsha/7f3e776 (fork: 1 commits, 1 day)
|__/                   |  x86_64-linux-gnu
 - PyCall                        1.6.3
 - PyPlot                        2.2.0+   985eb4bb  master
 - Conda                         0.2.2

tbreloff avatar Aug 02 '16 20:08 tbreloff

Here is the list of changes in 4.8.6 compared to 4.8.5. Nothing jumps out at me at first glance, though.

stevengj avatar Aug 02 '16 21:08 stevengj

I had a same problem. My solution was: installed matplotlib from the ubuntu repo (followed by this site) http://scipy.org/install.html

sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose

After I reinstalled PyPlot, and it works fine.

krisztiankosi avatar Aug 07 '16 23:08 krisztiankosi

Ubuntu repositories usually lag the latest version, so it's quite possible that the version of Qt you get from the repositories is 4.8.5 or earlier. It may still break in future.

I also don't see anything in the change log that jumps out. The advice I've seen for other problems with Qt is along the lines of "move to Qt5 as this is being actively developed" - is it worth trying it instead of Qt4?

swt30 avatar Aug 08 '16 00:08 swt30

We should certainly support the qt5 backend, but we can't stop people from specifying the qt4 backend.

stevengj avatar Aug 08 '16 01:08 stevengj

I'm worried that this issue is going to result in a bad first impression: 0.5 is released, a wave of people try it out, install PyPlot or Plots, get a segfault and swamp you and @tbreloff with complaints! But I don't know how one goes about understanding the cause of a segfault. I guess with Gallium up and running now it might be worth stepping through and seeing where the error occurs.

swt30 avatar Aug 18 '16 09:08 swt30

Well, the default backend is tk, so doesn't this only affect people if they (a) have the newer qt and (b) specify the qt backend in their .matplotlibrc?

@krisztiankosi's experience suggests that there may be some problem with matplotlib after all — if upgrading matplotlib fixes the problem, hopefully this will go away once Ubuntu has a newer matplotlib?

stevengj avatar Aug 18 '16 12:08 stevengj

@krisztiankosi, are you still using the qt backend? (Look at PyPlot.backend)

stevengj avatar Aug 18 '16 12:08 stevengj

the default backend is tk, so doesn't this only affect people if they (a) have the newer qt and (b) specify the qt backend in their .matplotlibrc?

I'm not sure if this is true. I think mine defaults to pyqt4? I never set anything in the .matplotlibrc, so it's using a default value from somewhere. I'm not at my ubuntu desktop right now so I can't check.

tbreloff avatar Aug 18 '16 12:08 tbreloff