Description
In JuliaPy/PyCall.jl#574 I wrote a PR to wrap every ccall
which invokes Python runtime with disable_sigint
. It seems that this is the right thing to do considering why disable_sigint
exists (and also because the main purpose of the PR was to use reenable_sigint
inside a callback).
While using this branch, I encountered a bug causing segfaults when calling it from PyJulia and I couldn't fix it. It occurs when I try to evaluate:
import DiffEqBase # not used but it was necessary somehow...
show(IOBuffer(), "text/plain", @doc Base.Enum) # must *not* have the docstring
from PyJulia. I ran git bisect
to find the change causing the segfault but the identified patch looks so harmless and identical to many others JuliaPy/PyCall.jl#574 (comment). I appreciate if core dev can have a look at it. It happens at Julia's internal and I don't know what is going on.
Here is the reproducible environment to invoke the segfault. You only need to run:
git clone https://gist.github.com/tkf/5f14bcc6957641be44f3bdba24e83a8c segfault
cd segfault
make
which is supposed to set up an isolated Julia and Python environments and run the script inside of it. It probably does not work when you use conda or Debian family to install python3
. Please let me know in such case.
As a side note, I couldn't turn the MWE to a Julia script. It seems that the Julia runtime has to be started via libjulia. (So I apologize in advance that the entry point is python3
...)
Here is a stacktrace:
signal (11): Segmentation fault
in expression starting at no file:0
jl_compile_linfo at /home/takafumi/repos/watch/julia/src/codegen.cpp:1173
emit_invoke at /home/takafumi/repos/watch/julia/src/codegen.cpp:3068
emit_expr at /home/takafumi/repos/watch/julia/src/codegen.cpp:3863
emit_ssaval_assign at /home/takafumi/repos/watch/julia/src/codegen.cpp:3585
emit_stmtpos at /home/takafumi/repos/watch/julia/src/codegen.cpp:3771 [inlined]
emit_function at /home/takafumi/repos/watch/julia/src/codegen.cpp:6203
jl_compile_linfo at /home/takafumi/repos/watch/julia/src/codegen.cpp:1141
emit_invoke at /home/takafumi/repos/watch/julia/src/codegen.cpp:3068
emit_expr at /home/takafumi/repos/watch/julia/src/codegen.cpp:3863
emit_ssaval_assign at /home/takafumi/repos/watch/julia/src/codegen.cpp:3585
emit_stmtpos at /home/takafumi/repos/watch/julia/src/codegen.cpp:3771 [inlined]
emit_function at /home/takafumi/repos/watch/julia/src/codegen.cpp:6203
jl_compile_linfo at /home/takafumi/repos/watch/julia/src/codegen.cpp:1141
jl_compile_method_internal at /home/takafumi/repos/watch/julia/src/gf.c:1808
jl_fptr_trampoline at /home/takafumi/repos/watch/julia/src/gf.c:1842
jl_apply_generic at /home/takafumi/repos/watch/julia/src/gf.c:2198
#with_output_color#660 at ./util.jl:366
unknown function (ip: 0x7f0e3586af27)
jl_fptr_trampoline at /home/takafumi/repos/watch/julia/src/gf.c:1843
jl_apply_generic at /home/takafumi/repos/watch/julia/src/gf.c:2198
with_output_color at ./util.jl:364 [inlined]
_term_header at /home/takafumi/repos/watch/julia/usr/share/julia/stdlib/v1.1/Markdown/src/render/terminal/render.jl:84
term at /home/takafumi/repos/watch/julia/usr/share/julia/stdlib/v1.1/Markdown/src/render/terminal/render.jl:101
unknown function (ip: 0x7f0e3586a724)
jl_fptr_trampoline at /home/takafumi/repos/watch/julia/src/gf.c:1843
jl_apply_generic at /home/takafumi/repos/watch/julia/src/gf.c:2198
term at /home/takafumi/repos/watch/julia/usr/share/julia/stdlib/v1.1/Markdown/src/render/terminal/render.jl:11
term at /home/takafumi/repos/watch/julia/usr/share/julia/stdlib/v1.1/Markdown/src/render/terminal/render.jl:17 [inlined]
term at /home/takafumi/repos/watch/julia/usr/share/julia/stdlib/v1.1/Markdown/src/render/terminal/render.jl:17 [inlined]
show at /home/takafumi/repos/watch/julia/usr/share/julia/stdlib/v1.1/Markdown/src/render/terminal/render.jl:169
jl_fptr_trampoline at /home/takafumi/repos/watch/julia/src/gf.c:1843
jl_apply_generic at /home/takafumi/repos/watch/julia/src/gf.c:2198
show at ./multimedia.jl:79
jl_fptr_trampoline at /home/takafumi/repos/watch/julia/src/gf.c:1843
jl_apply_generic at /home/takafumi/repos/watch/julia/src/gf.c:2198
do_call at /home/takafumi/repos/watch/julia/src/interpreter.c:323
eval_value at /home/takafumi/repos/watch/julia/src/interpreter.c:411
eval_stmt_value at /home/takafumi/repos/watch/julia/src/interpreter.c:362 [inlined]
eval_body at /home/takafumi/repos/watch/julia/src/interpreter.c:750
jl_interpret_toplevel_thunk_callback at /home/takafumi/repos/watch/julia/src/interpreter.c:880
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x7f0e486ce26f)
unknown function (ip: 0x2)
jl_interpret_toplevel_thunk at /home/takafumi/repos/watch/julia/src/interpreter.c:889
jl_toplevel_eval_flex at /home/takafumi/repos/watch/julia/src/toplevel.c:818
jl_toplevel_eval_in at /home/takafumi/repos/watch/julia/src/builtins.c:622
jl_eval_string at /home/takafumi/repos/watch/julia/src/jlapi.c:95
ffi_call_unix64 at /usr/lib/libffi.so.6 (unknown line)
ffi_call at /usr/lib/libffi.so.6 (unknown line)
_ctypes_callproc at /usr/lib/python3.7/lib-dynload/_ctypes.cpython-37m-x86_64-linux-gnu.so (unknown line)
unknown function (ip: 0x7f0e58e4d63f)
_PyObject_FastCallKeywords at /usr/lib/libpython3.7m.so.1.0 (unknown line)
_PyEval_EvalFrameDefault at /usr/lib/libpython3.7m.so.1.0 (unknown line)
_PyFunction_FastCallKeywords at /usr/lib/libpython3.7m.so.1.0 (unknown line)
_PyEval_EvalFrameDefault at /usr/lib/libpython3.7m.so.1.0 (unknown line)
_PyFunction_FastCallKeywords at /usr/lib/libpython3.7m.so.1.0 (unknown line)
_PyEval_EvalFrameDefault at /usr/lib/libpython3.7m.so.1.0 (unknown line)
_PyFunction_FastCallKeywords at /usr/lib/libpython3.7m.so.1.0 (unknown line)
_PyEval_EvalFrameDefault at /usr/lib/libpython3.7m.so.1.0 (unknown line)
_PyEval_EvalCodeWithName at /usr/lib/libpython3.7m.so.1.0 (unknown line)
PyEval_EvalCodeEx at /usr/lib/libpython3.7m.so.1.0 (unknown line)
PyEval_EvalCode at /usr/lib/libpython3.7m.so.1.0 (unknown line)
unknown function (ip: 0x7f0e5988c76f)
PyRun_FileExFlags at /usr/lib/libpython3.7m.so.1.0 (unknown line)
PyRun_SimpleFileExFlags at /usr/lib/libpython3.7m.so.1.0 (unknown line)
unknown function (ip: 0x7f0e59891a8e)
_Py_UnixMain at /usr/lib/libpython3.7m.so.1.0 (unknown line)
__libc_start_main at /usr/lib/libc.so.6 (unknown line)
_start at venv/bin/python (unknown line)
Allocations: 19617387 (Pool: 19613455; Big: 3932); GC: 40