-
-
Notifications
You must be signed in to change notification settings - Fork 198
Closed
Description
I'm trying to generate shared library using build_shared_lib which PackageCompiler.jl provides.
Here is my sample code named example.jl
module Example
Base.@ccallable empty()::Cint = 10
Base.@ccallable foo(x::Cint)::Cint = 3
Base.@ccallable function bar(x::Cint)::Cint
return 3
end
Base.@ccallable function just_print()::Cvoid
print("Example")
end
Base.@ccallable function bar_segfault(x::Cint)::Cint
println("Example")
return 3
end
Base.@ccallable function example(x::Cint)::Cint
return x
end
endApparently building shared object succeed by using the following the script named gen_lib.jl:
using PackageCompiler
build_shared_lib("example.jl")$ julia gen_lib.jlThis will create builddir/example.dylib.
The problem is some function works, but other cause segmentation fault.
Here is a code to reproduce our problem:
- environment
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.1.1 (2019-05-16)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> versioninfo()
Julia Version 1.1.1
Commit 55e36cc (2019-05-16 04:10 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin15.6.0)
CPU: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, skylake)- make call script named
call_example.jl
const dylibpath="builddir/example"
@show ccall((:foo,dylibpath),Cint,(Cint,),100)
@show ccall((:bar,dylibpath),Cint,(Cint,),100)
println("next :bar_segfauld will be seg fault...")
@show ccall((:bar_segfault,dylibpath),Cint,(Cint,),100)$ julia call_example.jl
ccall((:foo, dylibpath), Cint, (Cint,), 100) = 3
ccall((:bar, dylibpath), Cint, (Cint,), 100) = 3
next :bar_segfauld will be seg fault...
signal (11): Segmentation fault: 11
in expression starting at /Users/terasaki/tmp/sample/call_example.jl:7
unknown function (ip: 0xffffffffffffffff)
Allocations: 295934 (Pool: 295852; Big: 82); GC: 0
Segmentation fault: 11How do we use shared object Properly ?
schneiderfelipe
Metadata
Metadata
Assignees
Labels
No labels