Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault when using panel function of PyNGL #682

Closed
weech opened this issue Apr 29, 2019 · 4 comments
Closed

Segfault when using panel function of PyNGL #682

weech opened this issue Apr 29, 2019 · 4 comments

Comments

@weech
Copy link

weech commented Apr 29, 2019

Not sure what could be causing it. Here's a sample script to produce it (on Linux, Julia 1.1.0):

using PyCall
const ngl = pyimport("Ngl")

function main()

    arr1 = ngl.generate_2d_array([180, 360], 5, 4, -5, 6)
    arr2 = ngl.generate_2d_array([180, 360], 4, 3, -4, 5)

    lons = range(0, 360, length=360)
    lats = range(-90, 90, length=180)

    wks = ngl.open_wks("png", "pyngltest")
    res = ngl.Resources()
    res.sfXArray = lons
    res.sfYArray = lats
    res.nglDraw = false
    res.nglFrame = false

    plot1 = ngl.contour_map(wks, arr1, res)
    plot2 = ngl.contour_map(wks, arr2, res)
    ngl.panel(wks, [plot1, plot2], [2, 1])

    ngl.end()

end
main()

And the stacktrace:

signal (11): Segmentation fault
in expression starting at /home/alex/Documents/julia/pyngltest.jl:28
_wrap_panel_wrap at /home/alex/miniconda3/lib/python3.7/site-packages/ngl/_hlu.cpython-37m-x86_64-linux-gnu.so (unknown line)
_PyMethodDef_RawFastCallKeywords at /home/alex/miniconda3/lib/libpython3.7m.so.1.0 (unknown line)
_PyCFunction_FastCallKeywords at /home/alex/miniconda3/lib/libpython3.7m.so.1.0 (unknown line)
call_function.lto_priv.1536 at /home/alex/miniconda3/lib/libpython3.7m.so.1.0 (unknown line)
_PyEval_EvalFrameDefault at /home/alex/miniconda3/lib/libpython3.7m.so.1.0 (unknown line)
_PyEval_EvalCodeWithName at /home/alex/miniconda3/lib/libpython3.7m.so.1.0 (unknown line)
_PyFunction_FastCallDict at /home/alex/miniconda3/lib/libpython3.7m.so.1.0 (unknown line)
macro expansion at /home/alex/.julia/packages/PyCall/1815y/src/exception.jl:81 [inlined]
__pycall! at /home/alex/.julia/packages/PyCall/1815y/src/pyfncall.jl:44
_pycall! at /home/alex/.julia/packages/PyCall/1815y/src/pyfncall.jl:29
_pycall! at /home/alex/.julia/packages/PyCall/1815y/src/pyfncall.jl:11
jl_fptr_trampoline at /buildworker/worker/package_linux64/build/src/gf.c:1864
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2219
#call#111 at /home/alex/.julia/packages/PyCall/1815y/src/pyfncall.jl:89
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2219
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1571 [inlined]
jl_f__apply at /buildworker/worker/package_linux64/build/src/builtins.c:556
PyObject at /home/alex/.julia/packages/PyCall/1815y/src/pyfncall.jl:89
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2219
main at /home/alex/Documents/julia/pyngltest.jl:23
jl_fptr_trampoline at /buildworker/worker/package_linux64/build/src/gf.c:1864
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2219
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:323
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:411
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:362 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:773
jl_interpret_toplevel_thunk_callback at /buildworker/worker/package_linux64/build/src/interpreter.c:885
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x7f03977efe3f)
unknown function (ip: 0xffffffffffffffff)
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:894
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:764
jl_parse_eval_all at /buildworker/worker/package_linux64/build/src/ast.c:883
jl_load at /buildworker/worker/package_linux64/build/src/toplevel.c:826
include at ./boot.jl:326 [inlined]
include_relative at ./loading.jl:1038
include at ./sysimg.jl:29
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2219
exec_options at ./client.jl:267
_start at ./client.jl:436
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2219
unknown function (ip: 0x40191d)
unknown function (ip: 0x401523)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x4015c4)
Allocations: 9077386 (Pool: 9076307; Big: 1079); GC: 20

The same script in Python has no issues. I haven't had issues using any other PyNGL functions, but Ngl.panel causes Julia to crash every time.

@stevengj
Copy link
Member

Two common causes:

Could one of these two conditions apply?

@weech
Copy link
Author

weech commented Apr 29, 2019

No, I'm using the Julia from the downloads page on the website, and neither PyNGL nor any of the underlying NCL libraries make use of LLVM.

@stevengj
Copy link
Member

Try

pycall(ngl.generate_2d_array, PyObject, [180, 360], 5, 4, -5, 6)
pycall(ngl.generate_2d_array, PyObject, [180, 360], 4, 3, -4, 5)

in case it is getting confused by Julia arrays (e.g. if it falsely assumes all NumPy arrays are row-major it will get confused by Julia column-major NumPy arrays).

@weech
Copy link
Author

weech commented Apr 29, 2019

I tried that, and that doesn't work either. I went ahead and compiled PyNGL with debugging options, and it is segfaulting on the dims argument, the one that is [2, 1] in my example. I got it to break with Python by putting a np.array([2, 1]) in there, so basically this program does not accept NumPy arrays. I got it to work in Julia by passing dims as a tuple. Perhaps I should open an issue with PyNGL.

@weech weech closed this as completed Apr 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants