ConcurrencyViolationError in UnitfulExt

I get the following pre-compilation error:

⠇ [00m:15s] PackageCompiler: compiling incremental system image┌ Error: Error during loading of extension UnitfulExt of Plots, use `Base.retry_load_extensions()` to retry.
│   exception = 1-element ExceptionStack:
ConcurrencyViolationError("deadlock detected in loading UnitfulLatexify -> UnitfulLatexify && UnitfulExt")
Stacktrace:
  [1] start_loading(modkey::Base.PkgId)
    @ Base ./loading.jl:1637
  [2] _tryrequire_from_serialized(modkey::Base.PkgId, path::String, ocachepath::Nothing, sourcepath::String, depmods::Vector{Any})
    @ Base ./loading.jl:1469
  [3] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
    @ Base ./loading.jl:1574
  [4] _require(pkg::Base.PkgId, env::Nothing)
    @ Base ./loading.jl:1938
  [5] __require_prelocked(uuidkey::Base.PkgId, env::Nothing)
    @ Base ./loading.jl:1812
  [6] #invokelatest#2
    @ ./essentials.jl:892 [inlined]
  [7] invokelatest
    @ ./essentials.jl:889 [inlined]
  [8] _require_prelocked
    @ ./loading.jl:1805 [inlined]
  [9] _require_prelocked
    @ ./loading.jl:1802 [inlined]
 [10] run_extension_callbacks(extid::Base.ExtensionId)
    @ Base ./loading.jl:1295
 [11] run_extension_callbacks(pkgid::Base.PkgId)
    @ Base ./loading.jl:1330
 [12] run_package_callbacks(modkey::Base.PkgId)
    @ Base ./loading.jl:1164
 [13] _tryrequire_from_serialized(modkey::Base.PkgId, path::String, ocachepath::Nothing, sourcepath::String, depmods::Vector{Any})
    @ Base ./loading.jl:1487
 [14] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
    @ Base ./loading.jl:1574
 [15] _require(pkg::Base.PkgId, env::Nothing)
    @ Base ./loading.jl:1938
 [16] __require_prelocked(uuidkey::Base.PkgId, env::Nothing)
    @ Base ./loading.jl:1812
 [17] #invokelatest#2
    @ ./essentials.jl:892 [inlined]
 [18] invokelatest
    @ ./essentials.jl:889 [inlined]
 [19] _require_prelocked
    @ ./loading.jl:1805 [inlined]
 [20] _require_prelocked
    @ ./loading.jl:1802 [inlined]
 [21] macro expansion
    @ ./lock.jl:267 [inlined]
 [22] require(uuidkey::Base.PkgId)
    @ Base ./loading.jl:1797
 [23] top-level scope
    @ /tmp/jl_FIJiV8Hk7q:278
 [24] include(mod::Module, _path::String)
    @ Base ./Base.jl:495
 [25] exec_options(opts::Base.JLOptions)
    @ Base ./client.jl:318
 [26] _start()
    @ Base ./client.jl:552
└ @ Base loading.jl:1301

Is that a bug in Plots.jl ?

So far I cannot reproduce it without using PackageCompiler…

I got the same error message while creating a sysimage with my package.

Hi Uwe, I am reproducing the same error trying to install KiteSimulators.jl.

Welcome in the forum!

What is the output of

versioninfo()

from the Julia prompt?

Here is the output of

versioninfo()

Julia Version 1.10.3
Commit 0b4590a5507 (2024-04-30 10:59 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 12 × Intel(R) Core™ i7-9850H CPU @ 2.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
Threads: 1 default, 0 interactive, 1 GC (on 12 virtual cores)

1 Like

I think I will remove Plots.jl from KiteSimulators.jl and replace it with ControlPlots.jl, it is just causing too many hard-to-debug issues.

For the time beeing I suggest to use KiteControllers.jl directly:

mkdir repos
cd repos 
git clone https://github.com/aenarete/KiteControllers.jl
cd KiteControllers.jl/bin
time ./create_sys_image --update
./autopilot

repos is just the directory where I store my source code, could be any other directory.

Does this work for you? Creating the system image might take 30 minutes, but is only required once.

Instead of ./autopilot you can also do ./run_julia and then, at the julia prompt run include("examples/autopilot.jl"). I have alias jl='./bin/run_julia' in my .bashrc file to make my life easier.

On Linux you can also install the app as normal program running ./install .

I don’t know anything about your package but isn’t the normal way to integrate Plots in a larger package to define recipes and let the user take care of installing and then using Plots?

Thanks Uwe for this workaround, it worked (I just had one error as matplotlib was not used in the conda environment PyCall was pointing to, but after solving this, it was OK).

1 Like

I just tested this myself, and the error you got is actually only a warning and can safely be ignored… Just in case anybody else is reading this.

I am trying to get rid of this error without success. I removed all dependencies of Plots in my project, but the error sustains:

⢰ [00m:19s] PackageCompiler: compiling incremental system image┌ Error: Error during loading of extension UnitfulExt of Plots, use `Base.retry_load_extensions()` to retry.
│   exception = 1-element ExceptionStack:
ConcurrencyViolationError("deadlock detected in loading UnitfulLatexify -> UnitfulLatexify && UnitfulExt")
Stacktrace:
  [1] start_loading(modkey::Base.PkgId)
    @ Base ./loading.jl:1637
  [2] _tryrequire_from_serialized(modkey::Base.PkgId, path::String, ocachepath::Nothing, sourcepath::String, depmods::Vector{Any})
    @ Base ./loading.jl:1469

I do not have UnitfulLatexify in my Manifest.toml, and Unitful appears only as extension of DiffEqBase:

[[deps.DiffEqBase]]
deps = ["ArrayInterface", "ConcreteStructs", "DataStructures", "DocStringExtensions", "EnumX", "EnzymeCore", "FastBroadcast", "FastClosures", "ForwardDiff", "FunctionWrappers", "FunctionWrappersWrappers", "LinearAlgebra", "Logging", "Markdown", "MuladdMacro", "Parameters", "PreallocationTools", "PrecompileTools", "Printf", "RecursiveArrayTools", "Reexport", "SciMLBase", "SciMLOperators", "Setfield", "SparseArrays", "Static", "StaticArraysCore", "Statistics", "Tricks", "TruncatedStacktraces"]
git-tree-sha1 = "531c53fd0405716712a8b4960216c3b7b5ec89b9"
uuid = "2b5f629d-d688-5b77-993f-72d75c75574e"
version = "6.149.1"

    [deps.DiffEqBase.extensions]
    DiffEqBaseChainRulesCoreExt = "ChainRulesCore"
    DiffEqBaseDistributionsExt = "Distributions"
    DiffEqBaseEnzymeExt = ["ChainRulesCore", "Enzyme"]
    DiffEqBaseGeneralizedGeneratedExt = "GeneralizedGenerated"
    DiffEqBaseMPIExt = "MPI"
    DiffEqBaseMeasurementsExt = "Measurements"
    DiffEqBaseMonteCarloMeasurementsExt = "MonteCarloMeasurements"
    DiffEqBaseReverseDiffExt = "ReverseDiff"
    DiffEqBaseTrackerExt = "Tracker"
    DiffEqBaseUnitfulExt = "Unitful"

    [deps.DiffEqBase.weakdeps]
    ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
    Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
    Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
    GeneralizedGenerated = "6b9d7cbe-bcb9-11e9-073f-15a7a543e2eb"
    MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
    Measurements = "eff96d63-e80a-5855-80a2-b1b0885c5ab7"
    MonteCarloMeasurements = "0987c9cc-fe09-11e8-30f0-b96dd679fdca"
    ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
    Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"
    Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

Is this a bug in DiffEqBase?

I found a workaround/ solution:
Adding the parameter:

    include_transitive_dependencies=false

solves the issue.

The whole call now looks like this:

PackageCompiler.create_sysimage(
    [:KiteSimulators, :ControlPlots];
    sysimage_path="kps-image_tmp.so",
    include_transitive_dependencies=false,
    precompile_execution_file=joinpath("test", "test_for_precompile.jl")
)
2 Likes