I’ve been experimenting with using FunctionWrappers.jl. When I try to create a FunctionWrapper
for a function that doesn’t have a stable return type, I get a segfault. Is that a limitation of FunctionWrapper
, or is that a bug?
Here’s a simple example:
julia> using FunctionWrappers
julia> f = FunctionWrappers.FunctionWrapper{Any,Tuple{Int}}((x) -> iseven(x) ? 2.0 : 1)
FunctionWrappers.FunctionWrapper{Any,Tuple{Int64}}(Ptr{Nothing} @0x00000001221b7010, Ptr{Nothing} @0x00000001125fc390, Base.RefValue{getfield(Main, Symbol("##3#4"))}(getfield(Main, Symbol("##3#4"))()), getfield(Main, Symbol("##3#4")))
julia> f(1)
signal (11): Segmentation fault: 11
in expression starting at no file:0
unknown function (ip: 0x1221b70d0)
macro expansion at /Users/dmatz/.julia/packages/FunctionWrappers/mJrYu/src/FunctionWrappers.jl:111 [inlined]
do_ccall at /Users/dmatz/.julia/packages/FunctionWrappers/mJrYu/src/FunctionWrappers.jl:102 [inlined]
FunctionWrapper at /Users/dmatz/.julia/packages/FunctionWrappers/mJrYu/src/FunctionWrappers.jl:118
unknown function (ip: 0x1221ba966)
jl_fptr_trampoline at /Users/osx/buildbot/slave/package_osx64/build/src/gf.c:1864
do_call at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:323
eval_stmt_value at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:362 [inlined]
eval_body at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:759
jl_interpret_toplevel_thunk_callback at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:885
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x11488e3af)
unknown function (ip: 0xffffffffffffffff)
jl_interpret_toplevel_thunk at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:894
jl_toplevel_eval_flex at /Users/osx/buildbot/slave/package_osx64/build/src/toplevel.c:764
jl_toplevel_eval at /Users/osx/buildbot/slave/package_osx64/build/src/toplevel.c:773 [inlined]
jl_toplevel_eval_in at /Users/osx/buildbot/slave/package_osx64/build/src/toplevel.c:793
eval at ./boot.jl:328
eval_user_input at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:85
macro expansion at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:117 [inlined]
#26 at ./task.jl:259
jl_apply at /Users/osx/buildbot/slave/package_osx64/build/src/./julia.h:1571 [inlined]
start_task at /Users/osx/buildbot/slave/package_osx64/build/src/task.c:572
Allocations: 1516561 (Pool: 1516252; Big: 309); GC: 2
Segmentation fault: 11