Skip to content

reproducible segfault inside cfunction(...) #19805

@luchr

Description

@luchr

I'm trying to understand some ideas (which I was shown in JuliaMath/Cubature.jl#23) concerning elimination of dynamic dispatch. With the following code (which may be weird and silly; sorry I'm still learning) I always get a segfault simply by calling cfunction (even before trying to use the output pointer):

versioninfo()
type callinfos{FUNC_FT<:Function}
  f :: FUNC_FT
end

evalf_callback{FUNC_FT}(ci::callinfos{FUNC_FT}) = ci.f(0.5)::Float64

evalf_callback_c{FUNC_FT}(ci::callinfos{FUNC_FT}) = cfunction(
    evalf_callback, Float64, (callinfos{FUNC_FT},))

evalf_callback_c( callinfos(sin) )

Here is the output:

Julia Version 0.5.1-pre+31
Commit 6a1e339 (2016-11-17 17:50 UTC)
Platform Info:
  System: Linux (x86_64-redhat-linux)
  CPU: Intel(R) Core(TM) i7-4700MQ CPU @ 2.40GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, haswell)

signal (11): Segmentation fault
while loading <Path>/Desktop/mytest2.jl, in expression starting on line 12
unknown function (ip: 0x7f792313aa9f)
jl_function_ptr at <Path>/julia/julia_v0.5/src/codegen.cpp:982
evalf_callback_c at <Path>/Desktop/mytest2.jl:9
unknown function (ip: 0x7f76fc3df985)
jl_call_method_internal at <Path>/julia/julia_v0.5/src/julia_internal.h:189 [inlined]
jl_apply_generic at <Path>/julia/julia_v0.5/src/gf.c:1945
do_call at <Path>/julia/julia_v0.5/src/interpreter.c:66
eval at <Path>/julia/julia_v0.5/src/interpreter.c:190
jl_toplevel_eval_flex at <Path>/julia/julia_v0.5/src/toplevel.c:558
jl_parse_eval_all at <Path>/julia/julia_v0.5/src/ast.c:717
jl_load at <Path>/julia/julia_v0.5/src/toplevel.c:596
jl_load_ at <Path>/julia/julia_v0.5/src/toplevel.c:605
include_from_node1 at ./loading.jl:488
unknown function (ip: 0x7f791741c56b)
jl_call_method_internal at <Path>/julia/julia_v0.5/src/julia_internal.h:189 [inlined]
jl_apply_generic at <Path>/julia/julia_v0.5/src/gf.c:1945
process_options at ./client.jl:262
_start at ./client.jl:318
unknown function (ip: 0x7f7917441c78)
jl_call_method_internal at <Path>/julia/julia_v0.5/src/julia_internal.h:189 [inlined]
jl_apply_generic at <Path>/julia/julia_v0.5/src/gf.c:1945
jl_apply at <Path>/julia/julia_v0.5/ui/../src/julia.h:1392 [inlined]
true_main at <Path>/julia/julia_v0.5/ui/repl.c:112
main at <Path>/julia/julia_v0.5/ui/repl.c:232
__libc_start_main at /lib64/libc.so.6 (unknown line)
unknown function (ip: 0x4012c8)
Allocations: 2358732 (Pool: 2357723; Big: 1009); GC: 1
Segmentation fault (core dumped) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions