JuliaPy / PyPlot.jl

Plotting for Julia based on matplotlib.pyplot
https://github.com/JuliaPy/PyPlot.jl
MIT License
478 stars 88 forks source link

EXCEPTION_ACCESS_VIOLATION at 0x5c61bc01 -- PyObject_Call #360

Closed Datseris closed 6 years ago

Datseris commented 6 years ago

Hello. I am getting this error which is maddening me, because It did not happen in previous versions.

The problem is, I can't find which is the version that broke it...

I am pasting full steps to replicate, and error message and then I'll tell you more information on the error.

julia> ] develop https://github.com/JuliaDynamics/DynamicalBilliards.jl#namefield
julia> using DynamicalBilliards, PyPlot

julia> bd = billiard_bunimovich()
Billiard{Float64} with 4 obstacles:
  Bottom wall
  Right semicircle
  Top wall
  Left semicircle

julia> d = bd[2]
Right semicircle {Float64}
center: [1.0, 0.5]
radius: 0.5
facedir: [-1.0, 0.0]

julia> figure()
Figure(PyObject <Figure size 1000x798 with 0 Axes>)

julia> plot_obstacle!(d)

Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x5c61bc01 -- PyObject_Call at C:\Users\datseris\Anaconda3\python36.DLL (unknown line)
in expression starting at no file:0
PyObject_Call at C:\Users\datseris\Anaconda3\python36.DLL (unknown line)
macro expansion at C:\Users\datseris\.julia\packages\PyCall\fiJ3\src\exception.jl:81 [inlined]
#_pycall#82 at C:\Users\datseris\.julia\packages\PyCall\fiJ3\src\PyCall.jl:714
jl_fptr_trampoline at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:1823
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2140
jl_apply at /home/Administrator/buildbot/worker/package_win64/build/src\julia.h:1540 [inlined]
jl_f__apply at /home/Administrator/buildbot/worker/package_win64/build/src\builtins.c:561
#_pycall at .\<missing>:0
jl_fptr_trampoline at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:1823
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2140
jl_apply at /home/Administrator/buildbot/worker/package_win64/build/src\julia.h:1540 [inlined]
jl_f__apply at /home/Administrator/buildbot/worker/package_win64/build/src\builtins.c:561
#pycall#86 at C:\Users\datseris\.julia\packages\PyCall\fiJ3\src\PyCall.jl:731
jl_fptr_trampoline at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:1823
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2140
jl_apply at /home/Administrator/buildbot/worker/package_win64/build/src\julia.h:1540 [inlined]
jl_f__apply at /home/Administrator/buildbot/worker/package_win64/build/src\builtins.c:561
#pycall at .\<missing>:0
jl_fptr_trampoline at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:1823
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2140
jl_apply at /home/Administrator/buildbot/worker/package_win64/build/src\julia.h:1540 [inlined]
jl_f__apply at /home/Administrator/buildbot/worker/package_win64/build/src\builtins.c:561
#call#87 at C:\Users\datseris\.julia\packages\PyCall\fiJ3\src\PyCall.jl:734
jl_fptr_trampoline at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:1823
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2140
jl_apply at /home/Administrator/buildbot/worker/package_win64/build/src\julia.h:1540 [inlined]
jl_f__apply at /home/Administrator/buildbot/worker/package_win64/build/src\builtins.c:561
PyObject at .\<missing>:0
jl_fptr_trampoline at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:1823
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2140
jl_apply at /home/Administrator/buildbot/worker/package_win64/build/src\julia.h:1540 [inlined]
jl_f__apply at /home/Administrator/buildbot/worker/package_win64/build/src\builtins.c:499
#plot_obstacle!#57 at C:\Users\datseris\.julia\v0.6\DynamicalBilliards\src\plotting\obstacles.jl:39
jl_fptr_trampoline at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:1823
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2140 [inlined]
jl_apply at /home/Administrator/buildbot/worker/package_win64/build/src\julia.h:1540 [inlined]
jl_invoke at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:56
plot_obstacle! at C:\Users\datseris\.julia\v0.6\DynamicalBilliards\src\plotting\obstacles.jl:36
jl_fptr_trampoline at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:1823
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2140
do_call at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:324
eval_value at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:416
eval_body at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:559
jl_interpret_toplevel_thunk_callback at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:798
unknown function (ip: FFFFFFFFFFFFFFFE)
unknown function (ip: 00000000143EAEEF)
unknown function (ip: FFFFFFFFFFFFFFFF)
jl_toplevel_eval_flex at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:856
jl_toplevel_eval_in at /home/Administrator/buildbot/worker/package_win64/build/src\builtins.c:631
eval at .\boot.jl:316
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2140
eval_user_input at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\REPL\src\REPL.jl:85
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2140
macro expansion at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\REPL\src\REPL.jl:116 [inlined]
#28 at .\task.jl:254
jl_fptr_trampoline at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:1823
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2140
jl_apply at /home/Administrator/buildbot/worker/package_win64/build/src\julia.h:1540 [inlined]
start_task at /home/Administrator/buildbot/worker/package_win64/build/src\task.c:268
Allocations: 131064893 (Pool: 131048017; Big: 16876); GC: 313
PS C:\Users\datseris>

The function plot_obstacle! with this argument calls the following piece of code:

Arc = PyPlot.matplotlib[:patches][:Arc]

function plot_obstacle!(d::Semicircle; kwargs...)
    theta1 = atan(d.facedir[2], d.facedir[1])*180/π + 90
    theta2 = theta1 + 180
    edgecolor = (0,0.6,0)
    s1 = Arc(d.c, 2d.r, 2d.r, theta1 = theta1, theta2 = theta2, edgecolor = edgecolor,
    lw = 2.0, kwargs...)
    PyPlot.gca()[:add_artist](s1)
end

which is supposed to plot an arc. But then this error happens.

The real problem is that if I paste these code lines one by one in the REPL, everything works ok. But if I call them like a function I get that huge error and Julia crashes

:(

Datseris commented 6 years ago

Oh. This is on Julia 0.7-alpha.0 and [d330b81b] PyPlot v2.5.0 [438e738f] PyCall v1.17.1.

Notice something important: The exact same piece of code works on Julia 0.6 with

 - PyCall                        1.16.1
 - PyPlot                        2.5.0

(and a different branch of DynamicalBilliards of course).

I am using the same python installation in both 0.7 and 0.6 julia versions and related PyCall packages. This eliminates the problem coming from the Python distribution.

lhupe commented 6 years ago

on Linux (again using julia 0.7.0 alpha and the same PyPlot and PyCall versions) I get a slightly less verbose but similarily fatal error

julia> using DynamicalBilliards
┌ Warning: `convert(::Type{VersionNumber}, v::AbstractString)` is deprecated, use `VersionNumber(v)` instead.
│   caller = __init__() at init.jl:178
└ @ PyPlot init.jl:178

julia> bd = billiard_bunimovich()
Billiard{Float64} with 4 obstacles:
  Bottom wall
  Right semicircle
  Top wall
  Left semicircle

julia> o = bd[2]
Right semicircle {Float64}
center: [1.0, 0.5]
radius: 0.5
facedir: [-1.0, 0.0]

julia> plot_obstacle!(o)

signal (11): Segmentation fault
in expression starting at no file:0
PyObject_Call at /usr/lib/libpython3.6m.so (unknown line)
unknown function (ip: 0x7ffd39ff2a1f)
unknown function (ip: 0x7f8d76be1c7f)
Allocations: 67611774 (Pool: 67600853; Big: 10921); GC: 151
Segmentation fault (core dumped)
Datseris commented 6 years ago

Once again, this is the plot_obstacle! function:

Arc = PyPlot.matplotlib[:patches][:Arc]
function plot_obstacle!(d::Semicircle; kwargs...)
    theta1 = atan(d.facedir[2], d.facedir[1])*180/π + 90
    theta2 = theta1 + 180
    edgecolor = (0,0.6,0)
    s1 = Arc(d.c, 2d.r, 2d.r, theta1 = theta1, theta2 = theta2, edgecolor = edgecolor,
    lw = 2.0, kwargs...)
    PyPlot.gca()[:add_artist](s1)
end
Datseris commented 6 years ago

Hi @stevengj ! I am very happy to say that this is solved on current master. Can you please tag a new release and close this?

stevengj commented 6 years ago

A new release of PyCall or PyPlot?

stevengj commented 6 years ago

I just tagged a new PyPlot release.

Note that on master, the default backend has changed from qt to tk on some platforms — it could be that this is why you stopped hitting the crash.