Cfunction in runtest


I’m trying to port some older package (unregistered) to 1.0.
Strange is, the functionality works on REPL, but breaks with sig11 when run in runtests.

   _       _ _(_)_     |  Documentation:
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.0.3 (2018-12-18)
 _/ |\__'_|_|_|\__'_|  |  Official release
|__/                   |

julia> using Cairo

julia> using CairoScript
[ Info: Recompiling stale cache file /home/lobi/.julia/compiled/v1.0/CairoScript/zx0Ww.ji for CairoScript [22972aad-6828-5944-887c-95c4b9e553f7]
┌ Warning: Package CairoScript does not have Libdl in its dependencies:
│ - If you have CairoScript checked out for development and have
│   added Libdl as a dependency but haven't updated your primary
│   environment's manifest file, try `Pkg.resolve()`.
│ - Otherwise you may need to report an issue with CairoScript
└ Loading Libdl into CairoScript from project dependency, future warnings for CairoScript are suppressed.

julia> testfile = "../juliapackages/CairoScript/data/a1.cs"

julia> surf = CairoImageSurface(256, 256, Cairo.FORMAT_ARGB32)
Cairo.CairoSurfaceBase{UInt32}(Ptr{Nothing} @0x0000000001cdc0c0, 256.0, 256.0)

julia> h = CairoScript.InterpreterHooks()
CairoScript.InterpreterHooks(Ptr{Nothing} @0x0000000000000000, Ptr{Nothing} @0x0000000000000000, Ptr{Nothing} @0x0000000000000000, Ptr{Nothing} @0x0000000000000000, Ptr{Nothing} @0x0000000000000000, Ptr{Nothing} @0x0000000000000000, Ptr{Nothing} @0x0000000000000000, Ptr{Nothing} @0x0000000000000000)

julia> h.surface_create = CairoScript.surf_create_c[]
Ptr{Nothing} @0x00007f92b071b260

julia> h.closure = surf.ptr
Ptr{Nothing} @0x0000000001cdc0c0

julia> c = CairoScript.Interpreter()
CairoScript.Interpreter(Ptr{CairoScript.csi_t} @0x0000000001dd0f00)

julia> c = CairoScript.interpreter_install_hooks(c,h)
CairoScript.Interpreter(Ptr{CairoScript.csi_t} @0x0000000001dd0f00)

julia> mstatus = CairoScript.interpreter_run(c,testfile)

while this

   _       _ _(_)_     |  Documentation:
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.0.3 (2018-12-18)
 _/ |\__'_|_|_|\__'_|  |  Official release
|__/                   |

julia> using Pkg

julia> Pkg.test("CairoScript")
   Testing CairoScript
 Resolving package versions...
    Status `/tmp/tmpsouMRi/Manifest.toml`
  [9e28174c] BinDeps v0.8.10
  [b99e7846] BinaryProvider v0.5.3
  [e1450e63] BufferedStreams v1.0.0
  [159f3aea] Cairo v0.5.6+ [`~/.julia/dev/Cairo`]
  [22972aad] CairoScript v0.0.0 [`~/juliapackages/CairoScript`]
  [3da002f7] ColorTypes v0.7.5
  [5ae59095] Colors v0.9.5
  [34da2185] Compat v1.4.0
  [53c48c17] FixedPointNumbers v0.5.3
  [a2bd30eb] Graphics v0.4.0
  [0862f596] HTTPClient v0.2.1+ [`~/.julia/dev/HTTPClient`]
  [d9be37ee] Homebrew v0.7.0
  [682c06a0] JSON v0.20.0
  [b27032c2] LibCURL v0.4.1
  [522f3ed2] LibExpat v0.5.0
  [2ec943e9] Libz v1.0.0
  [77ba4419] NaNMath v0.3.2
  [189a3867] Reexport v0.2.0
  [30578b45] URIParser v0.4.0
  [c17dfb99] WinRPM v0.4.2
  [2a0f44e3] Base64  [`@stdlib/Base64`]
  [ade2ca70] Dates  [`@stdlib/Dates`]
  [8bb1440f] DelimitedFiles  [`@stdlib/DelimitedFiles`]
  [8ba89e20] Distributed  [`@stdlib/Distributed`]
  [b77e0a4c] InteractiveUtils  [`@stdlib/InteractiveUtils`]
  [76f85450] LibGit2  [`@stdlib/LibGit2`]
  [8f399da3] Libdl  [`@stdlib/Libdl`]
  [37e2e46d] LinearAlgebra  [`@stdlib/LinearAlgebra`]
  [56ddb016] Logging  [`@stdlib/Logging`]
  [d6f4376e] Markdown  [`@stdlib/Markdown`]
  [a63ad114] Mmap  [`@stdlib/Mmap`]
  [44cfe95a] Pkg  [`@stdlib/Pkg`]
  [de0858da] Printf  [`@stdlib/Printf`]
  [3fa0cd96] REPL  [`@stdlib/REPL`]
  [9a3f8284] Random  [`@stdlib/Random`]
  [ea8e919c] SHA  [`@stdlib/SHA`]
  [9e88b42a] Serialization  [`@stdlib/Serialization`]
  [1a1011a3] SharedArrays  [`@stdlib/SharedArrays`]
  [6462fe0b] Sockets  [`@stdlib/Sockets`]
  [2f01184e] SparseArrays  [`@stdlib/SparseArrays`]
  [10745b16] Statistics  [`@stdlib/Statistics`]
  [8dfed614] Test  [`@stdlib/Test`]
  [cf7118a7] UUIDs  [`@stdlib/UUIDs`]
  [4ec0a83e] Unicode  [`@stdlib/Unicode`]

signal (11): Segmentation fault
in expression starting at /home/lobi/juliapackages/CairoScript/test/runtests.jl:17
unknown function (ip: 0x7fb118c96890)
unknown function (ip: 0x1ba90ff)
Allocations: 4285352 (Pool: 4284623; Big: 729); GC: 8
ERROR: Package CairoScript errored during testing
 [1] pkgerror(::String, ::Vararg{String,N} where N) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/Types.jl:120
 [2] #test#65(::Bool, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:1357
 [3] #test at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:0 [inlined]
 [4] #test#42(::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:273
 [5] test at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:258 [inlined]
 [6] #test#41 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:255 [inlined]
 [7] test at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:255 [inlined]
 [8] #test#40 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:254 [inlined]
 [9] test at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:254 [inlined]
 [10] #test#39 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:253 [inlined]
 [11] test(::String) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:253
 [12] top-level scope at none:0

runs in runtests.jl the same thing.


Packages are precompiled by default in Julia 1.0, and I would guess that your deps.jl is not safe for precompilation. Can you try moving your include(depsfile) inside __init__ ?


The deps.jl is done by BinDeps and it’s just a single line library pointer. I’ve moved this inside the init and see the same problem.


Hmm, interesting. This still feels like a precompilation issue of some kind. Does setting __precompile__(false) in your module make any difference?




looks like a GC problem, you might need to temporarily shut down GC by:

GC.@preserve c begin
    mstatus = CairoScript.interpreter_run(c,testfile)


I put this clause into runtests but it fails the same way. I’m beginning to think i need a better way to debug, what actually fails in runtest.


instead of doing tests in REPL(global scope), you’d better wrap the code in a let block.


Maybe i wasn’t clear enough. The test break in runtests.jl which is called from Pkg.test and are collected into testset macros. These fail. Doing the same thing on the commanline without testset macros pass.