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

matshow plot segfault; seems gc related

Open jmxpearson opened this issue 10 years ago • 9 comments
trafficstars

Systems: Ubuntu 14.10 and OSX Libs: IJulia, PyCall, PyPlot all even with master

using PyPlot

matshow(rand(10, 10))

works from the Julia REPL but segfaults intermittently in the notebook. That is to say, it sometimes works once on recompilation of cache files but fails thereafter.

Here's the error output:

signal (11): Segmentation fault
_PyObject_GenericGetAttrWithDict at -------src-dir-------/Python-2.7.10/Objects/object.c:1430
PyEval_EvalFrameEx at -------src-dir-------/Python-2.7.10/Python/ceval.c:2272
PyEval_EvalCodeEx at -------src-dir-------/Python-2.7.10/Python/ceval.c:3267
function_call at -------src-dir-------/Python-2.7.10/Objects/funcobject.c:533
PyObject_Call at -------src-dir-------/Python-2.7.10/Objects/abstract.c:2529
ext_do_call at -------src-dir-------/Python-2.7.10/Python/ceval.c:4348
PyEval_EvalCodeEx at -------src-dir-------/Python-2.7.10/Python/ceval.c:3267
fast_function at -------src-dir-------/Python-2.7.10/Python/ceval.c:4131
PyEval_EvalCodeEx at -------src-dir-------/Python-2.7.10/Python/ceval.c:3267
function_call at -------src-dir-------/Python-2.7.10/Objects/funcobject.c:536
PyObject_Call at -------src-dir-------/Python-2.7.10/Objects/abstract.c:2529
instancemethod_call at -------src-dir-------/Python-2.7.10/Objects/classobject.c:2603
PyObject_Call at -------src-dir-------/Python-2.7.10/Objects/abstract.c:2529
do_call at -------src-dir-------/Python-2.7.10/Python/ceval.c:4253
PyEval_EvalCodeEx at -------src-dir-------/Python-2.7.10/Python/ceval.c:3267
function_call at -------src-dir-------/Python-2.7.10/Objects/funcobject.c:533
PyObject_Call at -------src-dir-------/Python-2.7.10/Objects/abstract.c:2529
ext_do_call at -------src-dir-------/Python-2.7.10/Python/ceval.c:4348
PyEval_EvalCodeEx at -------src-dir-------/Python-2.7.10/Python/ceval.c:3267
function_call at -------src-dir-------/Python-2.7.10/Objects/funcobject.c:533
PyObject_Call at -------src-dir-------/Python-2.7.10/Objects/abstract.c:2529
instancemethod_call at -------src-dir-------/Python-2.7.10/Objects/classobject.c:2603
PyObject_Call at -------src-dir-------/Python-2.7.10/Objects/abstract.c:2529
pycall at /home/pearson/.julia/v0.4/PyCall/src/exception.jl:78
unknown function (ip: 0x7f846b1b48b6)
jl_trampoline at /home/pearson/code/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
unknown function (ip: 0x7f846b1a7958)
jl_apply_generic at /home/pearson/code/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
unknown function (ip: 0x7f846b1b48b6)
jl_f_apply at /home/pearson/code/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
julia_pycall_22349 at  (unknown line)
unknown function (ip: 0x7f846b1b48b6)
jl_trampoline at /home/pearson/code/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
unknown function (ip: 0x7f846b1b48b6)
jl_f_kwcall at /home/pearson/code/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
unknown function (ip: 0x7f846b1b48b6)
jl_f_apply at /home/pearson/code/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
call at /home/pearson/.julia/v0.4/PyCall/src/PyCall.jl:407
julia_call_22347 at  (unknown line)
unknown function (ip: 0x7f846b1b48b6)
jl_trampoline at /home/pearson/code/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
unknown function (ip: 0x7f846b1b48b6)
jl_f_kwcall at /home/pearson/code/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
writemime at /home/pearson/.julia/v0.4/PyPlot/src/PyPlot.jl:309
jlcall_writemime_22346 at  (unknown line)
unknown function (ip: 0x7f846b1b48b6)
jl_trampoline at /home/pearson/code/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
unknown function (ip: 0x7f846b1a7958)
jl_apply_generic at /home/pearson/code/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
unknown function (ip: 0x7f846b1b48b6)
jl_f_apply at /home/pearson/code/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
base64encode at base64.jl:160
display_dict at /home/pearson/.julia/v0.4/IJulia/src/execute_request.jl:32
display at /home/pearson/.julia/v0.4/IJulia/src/inline.jl:35
jlcall_display_22304 at  (unknown line)
unknown function (ip: 0x7f846b1b48b6)
jl_trampoline at /home/pearson/code/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
unknown function (ip: 0x7f846b1a7958)
jl_apply_generic at /home/pearson/code/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
display at multimedia.jl:151
unknown function (ip: 0x7f846b1b48b6)
jl_trampoline at /home/pearson/code/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
unknown function (ip: 0x7f846b1a7958)
jl_apply_generic at /home/pearson/code/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
display at /home/pearson/.julia/v0.4/IJulia/src/inline.jl:56
execute_request_0x535c5df2 at /home/pearson/.julia/v0.4/IJulia/src/execute_request.jl:204
jlcall_execute_request_0x535c5df2_21705 at  (unknown line)
unknown function (ip: 0x7f846b1b48b6)
jl_trampoline at /home/pearson/code/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
unknown function (ip: 0x7f846b1a7958)
jl_apply_generic at /home/pearson/code/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
eventloop at /home/pearson/.julia/v0.4/IJulia/src/IJulia.jl:130
unknown function (ip: 0x7f846b1a7958)
jl_apply_generic at /home/pearson/code/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
anonymous at task.jl:448
unknown function (ip: 0x7f846b1b48b6)
jl_trampoline at /home/pearson/code/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
unknown function (ip: 0x7f846b251fae)
unknown function (ip: 0x7f846b2526d4)
unknown function (ip: (nil))

Note that some other plots work just fine, and matshow works after some other plots. For instance

using PyPlot

plot(rand(100))
matshow(rand(10, 10))

returns (in the notebook) the first plot, followed by

PyError (:PyObject_Call) <type 'exceptions.AttributeError'>
AttributeError("'Axes' object has no attribute '_animated'",)
  File "/home/pearson/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 2158, in print_figure
    **kwargs)
  File "/home/pearson/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 521, in print_png
    FigureCanvasAgg.draw(self)
  File "/home/pearson/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 469, in draw
    self.figure.draw(self.renderer)
  File "/home/pearson/anaconda/lib/python2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/home/pearson/anaconda/lib/python2.7/site-packages/matplotlib/figure.py", line 1082, in draw
    dsu = [row for row in dsu if not row[1].get_animated()]
  File "/home/pearson/anaconda/lib/python2.7/site-packages/matplotlib/artist.py", line 627, in get_animated
    return self._animated


 [inlined code] from /home/pearson/.julia/v0.4/PyCall/src/exception.jl:82
 in pycall at /home/pearson/.julia/v0.4/PyCall/src/PyCall.jl:387
 in call at /home/pearson/.julia/v0.4/PyCall/src/PyCall.jl:414
 in writemime at /home/pearson/.julia/v0.4/PyPlot/src/PyPlot.jl:310
 in base64encode at base64.jl:160
 in display_dict at /home/pearson/.julia/v0.4/IJulia/src/execute_request.jl:32
 in display at /home/pearson/.julia/v0.4/IJulia/src/inline.jl:35
 [inlined code] from multimedia.jl:151
 in display at multimedia.jl:162
 in display at /home/pearson/.julia/v0.4/IJulia/src/inline.jl:56

Putting the two plot calls in different cells works just fine.

Important: This error goes away if I remove the finalizer from PyObject, which is why I suspect it's gc-related. I've spent more time than I'd like to admit working on this, so I figured I report it.

jmxpearson avatar Sep 18 '15 18:09 jmxpearson

Btw, this is now fixed on my mac for Julia 4.1 and PyPlot, PyCall, and IJulia on master.

jmxpearson avatar Nov 10 '15 01:11 jmxpearson

Oh, great....I guess. Maybe it was a bug in Julia? It's a little disturbing that we never figured out the source of the error.

stevengj avatar Nov 13 '15 13:11 stevengj

Please re-open if the problem re-appears.

stevengj avatar Nov 13 '15 13:11 stevengj

I think some of the GC bug fixes probably took care of it. Works on my Linux machine as well.

jmxpearson avatar Nov 13 '15 13:11 jmxpearson

I am running into the same problem on Julia v0.4.0 so if for op the problem is gone with 0.4.1 then there was a regression there.

vchuravy avatar Dec 03 '15 12:12 vchuravy

I'm seeing this issue too, running Julia 0.4.5 in Arch Linux.

anjefu avatar Apr 14 '16 17:04 anjefu

Can you try Pkg.checkout("PyCall"); Pkg.build("PyCall") to see if the latest master of PyCall fixes the problem?

stevengj avatar Apr 14 '16 20:04 stevengj

This seems to fix it. I could call matshow hundreds of times without an issue. If I revert to PyCall 1.4.0 it crashes again almost immediately.

anjefu avatar Apr 14 '16 21:04 anjefu

Great! I'm planning to tag a new PyCall version pretty soon, so at that point we can close this again.

stevengj avatar Apr 14 '16 21:04 stevengj