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

reproducible segfault inside cfunction(...) #19805

Closed
luchr opened this issue Jan 1, 2017 · 3 comments · Fixed by #22079
Closed

reproducible segfault inside cfunction(...) #19805

luchr opened this issue Jan 1, 2017 · 3 comments · Fixed by #22079
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@luchr
Copy link

luchr commented Jan 1, 2017

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) 

@vtjnash vtjnash added the bug Indicates an unexpected problem or unintended behavior label Jan 1, 2017
@vtjnash
Copy link
Member

vtjnash commented Jan 1, 2017

Looks like something isn't restoring the builder context correctly

@KristofferC
Copy link
Member

KristofferC commented May 25, 2017

Now:

julia> type callinfos{FUNC_FT<:Function}
         f :: FUNC_FT
       end

julia> evalf_callback{FUNC_FT}(ci::callinfos{FUNC_FT}) = ci.f(0.5)::Float64
evalf_callback (generic function with 1 method)

julia> evalf_callback_c{FUNC_FT}(ci::callinfos{FUNC_FT}) = cfunction(
           evalf_callback, Float64, (callinfos{FUNC_FT},))
evalf_callback_c (generic function with 1 method)

julia> evalf_callback_c( callinfos(sin) )
ERROR: ccall: the type of argument 1 doesn't correspond to a C type
Stacktrace:
 [1] evalf_callback_c(::callinfos{Base.#sin}) at ./REPL[6]:1

@luchr
Copy link
Author

luchr commented May 26, 2017

"Now" means Julia v0.6 and v0.7 (= trunk). So for this versions the above message is the right error message to show. So fixed since v0.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants