# AssertionError: 0 \< tid \<= length(THREAD\_RNGs) during compilation with PackageCompiler

**URL:** <https://discourse.julialang.org/t/assertionerror-0-tid-length-thread-rngs-during-compilation-with-packagecompiler/69179>\
**Category:** New to Julia\
**Tags:** question, package\
**Created:** [October 4, 2021, 10:49am UTC](https://discourse.julialang.org/t/assertionerror-0-tid-length-thread-rngs-during-compilation-with-packagecompiler/69179 "2021-10-04T10:49:21Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![clarakoehne](https://avatars.discourse-cdn.com/v4/letter/c/ea5d25/32.png) [@clarakoehne](https://discourse.julialang.org/u/clarakoehne)\
**Post date:** [October 4, 2021, 10:49am UTC](https://discourse.julialang.org/t/assertionerror-0-tid-length-thread-rngs-during-compilation-with-packagecompiler/69179/1 "2021-10-04T10:49:21Z")

</div>

Hey there,  
I’m trying to compile a project using the `PackageCompiler` module. The compilation is part of a `conda build` process, i.e. I’m trying to make and upload a bioconda package from my project. However, I get the following error during compilation: `ERROR: LoadError: LoadError: LoadError: LoadError: AssertionError: 0 < tid <= length(THREAD_RNGs)`  
See Stacktrace below. I am using the 1.6.2 version of Julia and the 1.6.0 PackageCompiler.

```julia
09:06:16 BIOCONDA INFO (OUT) [ Info: PackageCompiler: creating system image object file, this might take a while...
.
09:06:57 BIOCONDA INFO (OUT) ┌ Info: Compiling bit-parallel GC counter for LongSequence{<:NucleicAcidAlphabet}
09:06:57 BIOCONDA INFO (OUT) └ @ BioSequences /home/conda/.julia/packages/BioSequences/k4j4J/src/longsequences/counting.jl:9
09:06:58 BIOCONDA INFO (OUT) ┌ Info: Compiling bit-parallel mismatch counter for LongSequence{<:NucleicAcidAlphabet}
09:06:58 BIOCONDA INFO (OUT) └ @ BioSequences /home/conda/.julia/packages/BioSequences/k4j4J/src/longsequences/counting.jl:26
09:06:58 BIOCONDA INFO (OUT) ┌ Info: Compiling bit-parallel match counter for LongSequence{<:NucleicAcidAlphabet}
09:06:58 BIOCONDA INFO (OUT) └ @ BioSequences /home/conda/.julia/packages/BioSequences/k4j4J/src/longsequences/counting.jl:46
09:06:58 BIOCONDA INFO (OUT) ┌ Info: Compiling bit-parallel ambiguity counter...
09:06:58 BIOCONDA INFO (OUT) └ @ BioSequences /home/conda/.julia/packages/BioSequences/k4j4J/src/longsequences/counting.jl:73
09:06:58 BIOCONDA INFO (OUT) ┌ Info: For a single LongSequence{<:NucleicAcidAlphabet}
09:06:58 BIOCONDA INFO (OUT) └ @ BioSequences /home/conda/.julia/packages/BioSequences/k4j4J/src/longsequences/counting.jl:74
09:06:58 BIOCONDA INFO (OUT) ┌ Info: For a pair of LongSequence{<:NucleicAcidAlphabet}s
09:06:58 BIOCONDA INFO (OUT) └ @ BioSequences /home/conda/.julia/packages/BioSequences/k4j4J/src/longsequences/counting.jl:88
09:06:58 BIOCONDA INFO (OUT) ┌ Info: Compiling bit-parallel certainty counter for LongSequence{<:NucleicAcidAlphabet}
09:06:58 BIOCONDA INFO (OUT) └ @ BioSequences /home/conda/.julia/packages/BioSequences/k4j4J/src/longsequences/counting.jl:119
09:06:58 BIOCONDA INFO (OUT) ┌ Info: Compiling bit-parallel gap counter for LongSequence{<:NucleicAcidAlphabet}
09:06:58 BIOCONDA INFO (OUT) └ @ BioSequences /home/conda/.julia/packages/BioSequences/k4j4J/src/longsequences/counting.jl:140
09:07:01 BIOCONDA INFO (OUT) ERROR: LoadError: LoadError: LoadError: LoadError: AssertionError: 0 < tid <= length(THREAD_RNGs)
09:07:01 BIOCONDA INFO (OUT) Stacktrace:
09:07:01 BIOCONDA INFO (OUT) [1] _rng_length_assert()
09:07:01 BIOCONDA INFO (OUT) @ Random /opt/conda/conda-bld/patchwork_1633337321114/_build_env/share/julia/stdlib/v1.6/Random/src/RNGs.jl:381
09:07:01 BIOCONDA INFO (OUT) [2] default_rng(tid::Int64)
09:07:01 BIOCONDA INFO (OUT) @ Random /opt/conda/conda-bld/patchwork_1633337321114/_build_env/share/julia/stdlib/v1.6/Random/src/RNGs.jl:372
09:07:01 BIOCONDA INFO (OUT) [3] default_rng
09:07:01 BIOCONDA INFO (OUT) @ /opt/conda/conda-bld/patchwork_1633337321114/_build_env/share/julia/stdlib/v1.6/Random/src/RNGs.jl:370 [inlined]
09:07:01 BIOCONDA INFO (OUT) [4] rand(#unused#::Type{Int64})
09:07:01 BIOCONDA INFO (OUT) @ Random /opt/conda/conda-bld/patchwork_1633337321114/_build_env/share/julia/stdlib/v1.6/Random/src/Random.jl:259
09:07:01 BIOCONDA INFO (OUT) [5] top-level scope
09:07:01 BIOCONDA INFO (OUT) @ ~/.julia/packages/BioSequences/k4j4J/src/longsequences/randseq.jl:11
09:07:01 BIOCONDA INFO (OUT) [6] include(mod::Module, _path::String)
09:07:01 BIOCONDA INFO (OUT) @ Base ./Base.jl:386
09:07:01 BIOCONDA INFO (OUT) [7] include(x::String)
09:07:01 BIOCONDA INFO (OUT) @ BioSequences ~/.julia/packages/BioSequences/k4j4J/src/BioSequences.jl:8
09:07:01 BIOCONDA INFO (OUT) [8] top-level scope
09:07:01 BIOCONDA INFO (OUT) @ ~/.julia/packages/BioSequences/k4j4J/src/BioSequences.jl:284
09:07:01 BIOCONDA INFO (OUT) [9] include
09:07:01 BIOCONDA INFO (OUT) @ ./Base.jl:386 [inlined]
09:07:01 BIOCONDA INFO (OUT) [10] _require(pkg::Base.PkgId)
09:07:01 BIOCONDA INFO (OUT) @ Base ./loading.jl:1072
09:07:01 BIOCONDA INFO (OUT) [11] require(uuidkey::Base.PkgId)
09:07:01 BIOCONDA INFO (OUT) @ Base ./loading.jl:936
09:07:01 BIOCONDA INFO (OUT) [12] require(into::Module, mod::Symbol)
09:07:01 BIOCONDA INFO (OUT) @ Base ./loading.jl:923
09:07:01 BIOCONDA INFO (OUT) [13] include
09:07:01 BIOCONDA INFO (OUT) @ ./Base.jl:386 [inlined]
09:07:01 BIOCONDA INFO (OUT) [14] _require(pkg::Base.PkgId)
09:07:01 BIOCONDA INFO (OUT) @ Base ./loading.jl:1072
09:07:01 BIOCONDA INFO (OUT) [15] require(uuidkey::Base.PkgId)
09:07:01 BIOCONDA INFO (OUT) @ Base ./loading.jl:936
09:07:01 BIOCONDA INFO (OUT) [16] require(into::Module, mod::Symbol)
09:07:01 BIOCONDA INFO (OUT) @ Base ./loading.jl:923
09:07:01 BIOCONDA INFO (OUT) [17] include
09:07:01 BIOCONDA INFO (OUT) @ ./Base.jl:386 [inlined]
09:07:01 BIOCONDA INFO (OUT) [18] _require(pkg::Base.PkgId)
09:07:01 BIOCONDA INFO (OUT) @ Base ./loading.jl:1072
09:07:01 BIOCONDA INFO (OUT) [19] require(uuidkey::Base.PkgId)
09:07:01 BIOCONDA INFO (OUT) @ Base ./loading.jl:936
09:07:01 BIOCONDA INFO (OUT) [20] require(into::Module, mod::Symbol)
09:07:01 BIOCONDA INFO (OUT) @ Base ./loading.jl:923
09:07:01 BIOCONDA INFO (OUT) in expression starting at /home/conda/.julia/packages/BioSequences/k4j4J/src/longsequences/randseq.jl:11
09:07:01 BIOCONDA INFO (OUT) in expression starting at /home/conda/.julia/packages/BioSequences/k4j4J/src/BioSequences.jl:8
09:07:01 BIOCONDA INFO (OUT) in expression starting at /home/conda/.julia/packages/BioAlignments/t4D8A/src/BioAlignments.jl:3
09:07:01 BIOCONDA INFO (OUT) in expression starting at /opt/conda/conda-bld/patchwork_1633337321114/work/src/Patchwork.jl:4
09:07:02 BIOCONDA INFO (OUT) ERROR: LoadError: failed process: Process(`/opt/conda/conda-bld/patchwork_1633337321114/_build_env/bin/julia --color=yes --startup-file=no '--cpu-target=generic;sandybridge,-xsaveopt,clone_all;haswell,-rdrnd,base(1)' --sysimage=/tmp/jl_9MfIes/tmp_sys.so --project=/opt/conda/conda-bld/patchwork_1633337321114/work --output-o=/tmp/jl_kN83dR.o -e "Base.reinit_stdio()
09:07:02 BIOCONDA INFO (OUT) @eval Sys BINDIR = ccall(:jl_get_julia_bindir, Any, ())::String
09:07:02 BIOCONDA INFO (OUT) @eval Sys STDLIB = \"/opt/conda/conda-bld/patchwork_1633337321114/_build_env/share/julia/stdlib/v1.6\"
09:07:02 BIOCONDA INFO (OUT) Base.init_load_path()
09:07:02 BIOCONDA INFO (OUT) if isdefined(Base, :init_active_project)
09:07:02 BIOCONDA INFO (OUT) Base.init_active_project()
09:07:02 BIOCONDA INFO (OUT) end
09:07:02 BIOCONDA INFO (OUT) Base.init_depot_path()
09:07:02 BIOCONDA INFO (OUT) import Patchwork
09:07:02 BIOCONDA INFO (OUT) # This @eval prevents symbols from being put into Main
09:07:02 BIOCONDA INFO (OUT) @eval Module() begin
09:07:02 BIOCONDA INFO (OUT) using Base.Meta
09:07:02 BIOCONDA INFO (OUT) PrecompileStagingArea = Module()
09:07:02 BIOCONDA INFO (OUT) for (_pkgid, _mod) in Base.loaded_modules
09:07:02 BIOCONDA INFO (OUT) if !(_pkgid.name in (\"Main\", \"Core\", \"Base\"))
09:07:02 BIOCONDA INFO (OUT) eval(PrecompileStagingArea, :(const \$(Symbol(_mod)) = \$_mod))
09:07:02 BIOCONDA INFO (OUT) end
09:07:02 BIOCONDA INFO (OUT) end
09:07:02 BIOCONDA INFO (OUT) precompile_files = String[
09:07:02 BIOCONDA INFO (OUT) \"/tmp/jl_VZQiK8\"
09:07:02 BIOCONDA INFO (OUT) \"/opt/conda/conda-bld/patchwork_1633337321114/work/src/precompiled.jl\"
09:07:02 BIOCONDA INFO (OUT) ]
09:07:02 BIOCONDA INFO (OUT) for file in precompile_files, statement in eachline(file)
09:07:02 BIOCONDA INFO (OUT) try
09:07:02 BIOCONDA INFO (OUT) # println(statement)
09:07:02 BIOCONDA INFO (OUT) # This is taken from https://github.com/JuliaLang/julia/blob/2c9e051c460dd9700e6814c8e49cc1f119ed8b41/contrib/generate_precompile.jl#L375-L393
09:07:02 BIOCONDA INFO (OUT) ps = Meta.parse(statement)
09:07:02 BIOCONDA INFO (OUT) isexpr(ps, :call) || continue
09:07:02 BIOCONDA INFO (OUT) popfirst!(ps.args) # precompile(...)
09:07:02 BIOCONDA INFO (OUT) ps.head = :tuple
09:07:02 BIOCONDA INFO (OUT) l = ps.args[end]
09:07:02 BIOCONDA INFO (OUT) if (isexpr(l, :tuple) || isexpr(l, :curly)) && length(l.args) > 0 # Tuple{...} or (...)
09:07:02 BIOCONDA INFO (OUT) # XXX: precompile doesn't currently handle overloaded Vararg arguments very well.
09:07:02 BIOCONDA INFO (OUT) # Replacing N with a large number works around it.
09:07:02 BIOCONDA INFO (OUT) l = l.args[end]
09:07:02 BIOCONDA INFO (OUT) if isexpr(l, :curly) && length(l.args) == 2 && l.args[1] === :Vararg # Vararg{T}
09:07:02 BIOCONDA INFO (OUT) push!(l.args, 100) # form Vararg{T, 100} instead
09:07:02 BIOCONDA INFO (OUT) end
09:07:02 BIOCONDA INFO (OUT) end
09:07:02 BIOCONDA INFO (OUT) # println(ps)
09:07:02 BIOCONDA INFO (OUT) ps = Core.eval(PrecompileStagingArea, ps)
09:07:02 BIOCONDA INFO (OUT) # XXX: precompile doesn't currently handle overloaded nospecialize arguments very well.
09:07:02 BIOCONDA INFO (OUT) # Skipping them avoids the warning.
09:07:02 BIOCONDA INFO (OUT) ms = length(ps) == 1 ? Base._methods_by_ftype(ps[1], 1, Base.get_world_counter()) : Base.methods(ps...)
09:07:02 BIOCONDA INFO (OUT) ms isa Vector || continue
09:07:02 BIOCONDA INFO (OUT) precompile(ps...)
09:07:02 BIOCONDA INFO (OUT) catch e
09:07:02 BIOCONDA INFO (OUT) # See julia issue #28808
09:07:02 BIOCONDA INFO (OUT) @debug \"failed to execute \$statement\"
09:07:02 BIOCONDA INFO (OUT) end
09:07:02 BIOCONDA INFO (OUT) end
09:07:02 BIOCONDA INFO (OUT) end # module
09:07:02 BIOCONDA INFO (OUT) Base.@ccallable function julia_main()::Cint
09:07:02 BIOCONDA INFO (OUT) try
09:07:02 BIOCONDA INFO (OUT) Patchwork.julia_main()
09:07:02 BIOCONDA INFO (OUT) catch
09:07:02 BIOCONDA INFO (OUT) Core.print(\"julia_main() threw an unhandled exception\")
09:07:02 BIOCONDA INFO (OUT) return 1
09:07:02 BIOCONDA INFO (OUT) end
09:07:02 BIOCONDA INFO (OUT) end
09:07:02 BIOCONDA INFO (OUT) empty!(LOAD_PATH)
09:07:02 BIOCONDA INFO (OUT) empty!(DEPOT_PATH)
09:07:02 BIOCONDA INFO (OUT) "`, ProcessExited(1)) [1]
09:07:02 BIOCONDA INFO (OUT) 
09:07:02 BIOCONDA INFO (OUT) Stacktrace:
09:07:02 BIOCONDA INFO (OUT) [1] pipeline_error
09:07:02 BIOCONDA INFO (OUT) @ ./process.jl:525 [inlined]
09:07:02 BIOCONDA INFO (OUT) [2] run(::Cmd; wait::Bool)
09:07:02 BIOCONDA INFO (OUT) @ Base ./process.jl:440
09:07:02 BIOCONDA INFO (OUT) [3] run
09:07:02 BIOCONDA INFO (OUT) @ ./process.jl:438 [inlined]
09:07:02 BIOCONDA INFO (OUT) [4] create_sysimg_object_file(object_file::String, packages::Vector{String}; project::String, base_sysimage::String, precompile_execution_file::Vector{String}, precompile_statements_file::Vector{String}, cpu_target::String, script::Nothing, isapp::Bool, sysimage_build_args::Cmd)
09:07:02 BIOCONDA INFO (OUT) @ PackageCompiler ~/.julia/packages/PackageCompiler/r8Xcy/src/PackageCompiler.jl:371
09:07:02 BIOCONDA INFO (OUT) [5] create_sysimage(packages::Vector{String}; sysimage_path::String, project::String, precompile_execution_file::Vector{String}, precompile_statements_file::String, incremental::Bool, filter_stdlibs::Bool, replace_default::Bool, base_sysimage::String, isapp::Bool, julia_init_c_file::Nothing, version::Nothing, compat_level::String, soname::String, cpu_target::String, script::Nothing, sysimage_build_args::Cmd)
09:07:02 BIOCONDA INFO (OUT) @ PackageCompiler ~/.julia/packages/PackageCompiler/r8Xcy/src/PackageCompiler.jl:538
09:07:02 BIOCONDA INFO (OUT) [6] (::PackageCompiler.var"#14#16"{Bool, Nothing, Nothing, String, Cmd, String, Vector{String}, String, Bool, Bool, String, String, String, String, Bool})()
09:07:02 BIOCONDA INFO (OUT) @ PackageCompiler ~/.julia/packages/PackageCompiler/r8Xcy/src/PackageCompiler.jl:978
09:07:02 BIOCONDA INFO (OUT) [7] cd(f::PackageCompiler.var"#14#16"{Bool, Nothing, Nothing, String, Cmd, String, Vector{String}, String, Bool, Bool, String, String, String, String, Bool}, dir::String)
09:07:02 BIOCONDA INFO (OUT) @ Base.Filesystem ./file.jl:106
09:07:02 BIOCONDA INFO (OUT) [8] _create_app(package_dir::String, dest_dir::String, name::String, precompile_execution_file::Vector{String}, precompile_statements_file::String, incremental::Bool, filter_stdlibs::Bool, audit::Bool, force::Bool, cpu_target::String; library_only::Bool, c_driver_program::String, julia_init_c_file::Nothing, header_files::Vector{String}, version::Nothing
, compat_level::String, include_lazy_artifacts::Bool, sysimage_build_args::Cmd)
09:07:02 BIOCONDA INFO (OUT) @ PackageCompiler ~/.julia/packages/PackageCompiler/r8Xcy/src/PackageCompiler.jl:968
09:07:02 BIOCONDA INFO (OUT) [9] #create_app#11
09:07:02 BIOCONDA INFO (OUT) @ ~/.julia/packages/PackageCompiler/r8Xcy/src/PackageCompiler.jl:771 [inlined]
09:07:02 BIOCONDA INFO (OUT) [10] top-level scope
09:07:02 BIOCONDA INFO (OUT) @ /opt/conda/conda-bld/patchwork_1633337321114/work/src/compile.jl:21
09:07:02 BIOCONDA INFO (OUT) in expression starting at /opt/conda/conda-bld/patchwork_1633337321114/work/src/compile.jl:21
09:07:04 BIOCONDA INFO (OUT) Traceback (most recent call last):
09:07:04 BIOCONDA INFO (OUT) File "/opt/conda/bin/conda-build", line 11, in <module>
09:07:04 BIOCONDA INFO (OUT) sys.exit(main())
09:07:04 BIOCONDA INFO (OUT) File "/opt/conda/lib/python3.7/site-packages/conda_build/cli/main_build.py", line 481, in main
09:07:04 BIOCONDA INFO (OUT) execute(sys.argv[1:])
09:07:04 BIOCONDA INFO (OUT) File "/opt/conda/lib/python3.7/site-packages/conda_build/cli/main_build.py", line 472, in execute
09:07:04 BIOCONDA INFO (OUT) verify=args.verify, variants=args.variants, cache_dir=args.cache_dir)
09:07:04 BIOCONDA INFO (OUT) File "/opt/conda/lib/python3.7/site-packages/conda_build/api.py", line 195, in build
09:07:04 BIOCONDA INFO (OUT) variants=variants
09:07:04 BIOCONDA INFO (OUT) File "/opt/conda/lib/python3.7/site-packages/conda_build/build.py", line 3073, in build_tree
09:07:04 BIOCONDA INFO (OUT) notest=notest,
09:07:04 BIOCONDA INFO (OUT) File "/opt/conda/lib/python3.7/site-packages/conda_build/build.py", line 2192, in build
09:07:04 BIOCONDA INFO (OUT) cwd=src_dir, stats=build_stats)
09:07:04 BIOCONDA INFO (OUT) File "/opt/conda/lib/python3.7/site-packages/conda_build/utils.py", line 412, in check_call_env
09:07:04 BIOCONDA INFO (OUT) return _func_defaulting_env_to_os_environ('call', *popenargs, **kwargs)
09:07:04 BIOCONDA INFO (OUT) File "/opt/conda/lib/python3.7/site-packages/conda_build/utils.py", line 392, in _func_defaulting_env_to_os_environ
09:07:04 BIOCONDA INFO (OUT) raise subprocess.CalledProcessError(proc.returncode, _args)
09:07:04 BIOCONDA INFO (OUT) subprocess.CalledProcessError: Command '['/bin/bash', '-o', 'errexit', '/opt/conda/conda-bld/patchwork_1633337321114/work/conda_build.sh']' returned non-zero exit status 1.
09:07:16 BIOCONDA ERROR COMMAND FAILED (exited with 1): docker run -t --net host --rm -v /tmp/tmpqr8l0uzh/build_script.bash:/opt/build_script.bash -v /home/circleci/project/miniconda/conda-bld/:/opt/host-conda-bld -v /home/circleci/project/recipes/patchwork:/opt/recipe -e LANG=en_US.UTF-8 -e HOST_USER_ID=1001 quay.io/bioconda/bioconda-utils-build-env-cos7:0.17.8 /bin/bash /opt/build_script.bash

09:07:16 BIOCONDA ERROR BUILD FAILED recipes/patchwork
09:07:16 BIOCONDA INFO (COMMAND) conda build purge
09:07:18 BIOCONDA ERROR BUILD SUMMARY: of 1 recipes, 1 failed and 0 were skipped. Details of recipes and environments follow.
09:07:18 BIOCONDA ERROR BUILD SUMMARY: FAILED recipe recipes/patchwork

Exited with code exit status 1

```

I think the command that produces the error is `PackageCompiler.create_app(projectdirectory, outdirectory; precompile_statements_file = precompiled, force = true)`.  
Could someone help me please? Thanks!

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [October 5, 2021, 5:18am UTC](https://discourse.julialang.org/t/assertionerror-0-tid-length-thread-rngs-during-compilation-with-packagecompiler/69179/2 "2021-10-05T05:18:51Z")

</div>

The package is calling `rand` in toplevel

[https://github.com/BioJulia/BioSequences.jl/blob/08a67d75d9e2005caa32a6f300c20092d521c431/src/longsequences/randseq.jl#L11](https://github.com/BioJulia/BioSequences.jl/blob/08a67d75d9e2005caa32a6f300c20092d521c431/src/longsequences/randseq.jl#L11)

But the rng is not fully functional in the process that creates the sysimage. However, we precompile things first to avoid this problem. I will try check what is going on.

---

<div class="post-metadata">

**Author:** ![clarakoehne](https://avatars.discourse-cdn.com/v4/letter/c/ea5d25/32.png) [@clarakoehne](https://discourse.julialang.org/u/clarakoehne)\
**Post date:** [October 5, 2021, 1:23pm UTC](https://discourse.julialang.org/t/assertionerror-0-tid-length-thread-rngs-during-compilation-with-packagecompiler/69179/3 "2021-10-05T13:23:45Z")

</div>

Okay, thanks, that would be brilliant.

---

<div class="post-metadata">

**Author:** ![amckay1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amckay1/32/8280_2.png) [@amckay1](https://discourse.julialang.org/u/amckay1)\
**Post date:** [October 6, 2021, 1:30am UTC](https://discourse.julialang.org/t/assertionerror-0-tid-length-thread-rngs-during-compilation-with-packagecompiler/69179/4 "2021-10-06T01:30:05Z")

</div>

I just ran into this problem today, same assertion error. Thanks for looking into it!

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [October 6, 2021, 7:18am UTC](https://discourse.julialang.org/t/assertionerror-0-tid-length-thread-rngs-during-compilation-with-packagecompiler/69179/5 "2021-10-06T07:18:24Z")

</div>

[https://github.com/JuliaLang/PackageCompiler.jl/pull/579](https://github.com/JuliaLang/PackageCompiler.jl/pull/579) should fix it but I am still unclear why this is needed.

Also, I cannot reproduce this locally. More information about this would be good because it means an assumption I have is not completely correct.

For someone who has this error, could you run with ` ENV["JULIA_DEBUG"] = "loading"` before creating the sysimage?

---

<div class="post-metadata">

**Author:** ![clarakoehne](https://avatars.discourse-cdn.com/v4/letter/c/ea5d25/32.png) [@clarakoehne](https://discourse.julialang.org/u/clarakoehne)\
**Post date:** [October 6, 2021, 9:45am UTC](https://discourse.julialang.org/t/assertionerror-0-tid-length-thread-rngs-during-compilation-with-packagecompiler/69179/6 "2021-10-06T09:45:42Z")

</div>

Hmm. When I ran my `conda build` test again today, it worked fine. Creating the sysimage locally (independent from conda) didn’t error either. Should I still send the debug output?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [October 6, 2021, 1:34pm UTC](https://discourse.julialang.org/t/assertionerror-0-tid-length-thread-rngs-during-compilation-with-packagecompiler/69179/7 "2021-10-06T13:34:52Z")

</div>

Only useful when it errors. Anyway, I made a new release of PackageCompiler that should work around this even in the strange case. It should be available soon.

---

<div class="post-metadata">

**Author:** ![amckay1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amckay1/32/8280_2.png) [@amckay1](https://discourse.julialang.org/u/amckay1)\
**Post date:** [October 7, 2021, 1:28am UTC](https://discourse.julialang.org/t/assertionerror-0-tid-length-thread-rngs-during-compilation-with-packagecompiler/69179/8 "2021-10-07T01:28:59Z")

</div>

Updated to v1.7.0 and I no longer have that error, thank you again!

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [October 7, 2021, 12:33pm UTC](https://discourse.julialang.org/t/assertionerror-0-tid-length-thread-rngs-during-compilation-with-packagecompiler/69179/9 "2021-10-07T12:33:23Z")

</div>

Can you reliably reproduce it on PackageCompiler 1.6? In that case, could you explain how?

---

<div class="post-metadata">

**Author:** ![amckay1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amckay1/32/8280_2.png) [@amckay1](https://discourse.julialang.org/u/amckay1)\
**Post date:** [October 7, 2021, 3:27pm UTC](https://discourse.julialang.org/t/assertionerror-0-tid-length-thread-rngs-during-compilation-with-packagecompiler/69179/10 "2021-10-07T15:27:24Z")

</div>

So I rolled back to 1.6 and tried both locally and on the cluster and the assertion error returned. For reproducibility, I added XAM.jl to the MyApp example (added to dev’d package, only included “using XAM” in src/MyApp.jl) and it started failing with the same assertion error both locally and on the cluster.

I’m dealing with another issue or two ([PackageCompiler "create\_app" function failing on slurm cluster: "error: undefined reference to 'ceil'"](https://discourse.julialang.org/t/packagecompiler-create-app-function-failing-on-slurm-cluster-error-undefined-reference-to-ceil/69344)) but I don’t think that changes the conclusion that the PackageCompiler v1.6.0 issue can be reproduced with that XAM.jl package?

Please let me know if you need any more details!

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [October 7, 2021, 6:54pm UTC](https://discourse.julialang.org/t/assertionerror-0-tid-length-thread-rngs-during-compilation-with-packagecompiler/69179/11 "2021-10-07T18:54:09Z")

</div>

> [@amckay1](#):
>
> I added XAM.jl to the MyApp example (added to dev’d package, only included “using XAM” in src/MyApp.jl) and it started failing with the same assertion error both locally and on the cluster.

Thanks, I can repro! Great.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [October 7, 2021, 7:43pm UTC](https://discourse.julialang.org/t/assertionerror-0-tid-length-thread-rngs-during-compilation-with-packagecompiler/69179/12 "2021-10-07T19:43:22Z")

</div>

Are you creating an app or a sysimage? If you are creating an app, could you pass `incremental=false` to check if that works around it?

---

<div class="post-metadata">

**Author:** ![amckay1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amckay1/32/8280_2.png) [@amckay1](https://discourse.julialang.org/u/amckay1)\
**Post date:** [October 7, 2021, 8:43pm UTC](https://discourse.julialang.org/t/assertionerror-0-tid-length-thread-rngs-during-compilation-with-packagecompiler/69179/13 "2021-10-07T20:43:41Z")

</div>

I am trying to create an app, but unfortunately for neither the `error: undefined reference to 'ceil'` errors on the cluster nor the seg fault error locally (induced by trying to run post-compilation) does `incremental=false ` change anything.

Thank you again for your help and all ears for any other suggestions. Going to try dismantling my app or adding parts that might break the example app and see if anything changes. Will let you know if I find any possible causes.

---

<div class="post-metadata">

**Author:** ![zornsllama](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zornsllama/32/24636_2.png) [@zornsllama](https://discourse.julialang.org/u/zornsllama)\
**Post date:** [October 12, 2021, 4:21am UTC](https://discourse.julialang.org/t/assertionerror-0-tid-length-thread-rngs-during-compilation-with-packagecompiler/69179/14 "2021-10-12T04:21:29Z")

</div>

Using PackageCompiler 1.7.2, I am still running into precisely this error when attempting to generate a sysimage containing Makie packages. The offending dependency appears to be TiffImages. I did not have this issue when precompiling Makie for my previous Julia installation (I recently upgraded from Julia 1.6.2 to 1.6.3). Is there any workaround/fix I can do here?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [October 12, 2021, 4:58am UTC](https://discourse.julialang.org/t/assertionerror-0-tid-length-thread-rngs-during-compilation-with-packagecompiler/69179/15 "2021-10-12T04:58:56Z")

</div>

Please provide full details of how you create the sysimage so it can possibly be reproduced.

---

<div class="post-metadata">

**Author:** ![TheLateKronos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thelatekronos/32/12824_2.png) [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Post date:** [October 28, 2021, 1:14pm UTC](https://discourse.julialang.org/t/assertionerror-0-tid-length-thread-rngs-during-compilation-with-packagecompiler/69179/16 "2021-10-28T13:14:49Z")

</div>

Same error for me with the latest version of PackageCompiler:

```julia
julia> generate_my_sysimage()
    Updating registry at `C:\Users\densb\.julia\registries\General`
    Updating git-repo `https://github.com/JuliaRegistries/General.git`
   Installed Pluto ───────────── v0.17.0
   Installed Unitful ─────────── v1.9.1
   Installed Parsers ─────────── v2.1.1
   Installed Symbolics ───────── v3.5.1
   Installed Flux ────────────── v0.12.8
   Installed Distributions ───── v0.25.23
   Installed PkgTemplates ────── v0.7.22
   Installed CSV ─────────────── v0.9.10
   Installed LoopVectorization ─ v0.12.90
    Updating `C:\Users\densb\.julia\environments\v1.6\Project.toml`
  [336ed68f] ↑ CSV v0.9.9 ⇒ v0.9.10
  [31c24e10] ↑ Distributions v0.25.22 ⇒ v0.25.23
  [587475ba] ↑ Flux v0.12.7 ⇒ v0.12.8
  [14b8a8f1] ↑ PkgTemplates v0.7.21 ⇒ v0.7.22
  [c3e4b0f8] ↑ Pluto v0.16.4 ⇒ v0.17.0
  [0c5d862f] ↑ Symbolics v3.5.0 ⇒ v3.5.1
  [1986cc42] ↑ Unitful v1.9.0 ⇒ v1.9.1
    Updating `C:\Users\densb\.julia\environments\v1.6\Manifest.toml`
  [336ed68f] ↑ CSV v0.9.9 ⇒ v0.9.10
  [31c24e10] ↑ Distributions v0.25.22 ⇒ v0.25.23
  [587475ba] ↑ Flux v0.12.7 ⇒ v0.12.8
  [bdcacae8] ↑ LoopVectorization v0.12.89 ⇒ v0.12.90
  [69de0a69] ↑ Parsers v2.1.0 ⇒ v2.1.1
  [14b8a8f1] ↑ PkgTemplates v0.7.21 ⇒ v0.7.22
  [c3e4b0f8] ↑ Pluto v0.16.4 ⇒ v0.17.0
  [0c5d862f] ↑ Symbolics v3.5.0 ⇒ v3.5.1
  [1986cc42] ↑ Unitful v1.9.0 ⇒ v1.9.1
Precompiling project...
  ✓ Unitful
  45 dependencies successfully precompiled in 288 seconds (375 already precompiled)
  1 dependency precompiled but a different version is currently loaded. Restart julia to access the new version
[ Info: PackageCompiler: Executing C:\Users\densb\GeekyStuff\Julia\sysimage\stuff_to_precompile.jl => C:\Users\densb\AppData\Local\Temp\jl_packagecompiler_OtVBp9\jl_1625.tmp
[ Info: PackageCompiler: Done
[ Info: PackageCompiler: creating system image object file, this might take a while...
ERROR: LoadError: LoadError: AssertionError: 0 < tid <= length(THREAD_RNGs)
Stacktrace:
  [1] _rng_length_assert()
    @ Random C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Random\src\RNGs.jl:381
  [2] default_rng(tid::Int64)
    @ Random C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Random\src\RNGs.jl:372
  [3] default_rng
    @ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Random\src\RNGs.jl:370 [inlined]
  [4] rand! (repeats 2 times)
    @ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Random\src\Random.jl:264 [inlined]
  [5] _rand(#unused#::Type{ColorTypes.Gray{FixedPointNumbers.N0f8}}, sz::Tuple{Int64, Int64})
    @ ColorTypes C:\Users\densb\.julia\packages\ColorTypes\6m8P7\src\operations.jl:97
  [6] rand
    @ C:\Users\densb\.julia\packages\ColorTypes\6m8P7\src\operations.jl:120 [inlined]
  [7] rand(#unused#::Type{ColorTypes.Gray{FixedPointNumbers.N0f8}}, d::Int64, dims::Int64)
    @ Random C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Random\src\Random.jl:292
  [8] (::TiffImages.var"#14#15")(fpath::String, #unused#::IOStream)
    @ TiffImages C:\Users\densb\.julia\packages\TiffImages\XzftO\src\TiffImages.jl:40
  [9] mktemp(fn::TiffImages.var"#14#15", parent::String)
    @ Base.Filesystem .\file.jl:703
 [10] mktemp(fn::Function)
    @ Base.Filesystem .\file.jl:701
 [11] top-level scope
    @ C:\Users\densb\.julia\packages\TiffImages\XzftO\src\TiffImages.jl:37
 [12] include
    @ .\Base.jl:386 [inlined]
 [13] _require(pkg::Base.PkgId)
    @ Base .\loading.jl:1072
 [14] require(uuidkey::Base.PkgId)
    @ Base .\loading.jl:936
 [15] top-level scope
    @ C:\Users\densb\AppData\Local\Temp\jl_5XxI3XTk6d:37
in expression starting at C:\Users\densb\.julia\packages\TiffImages\XzftO\src\TiffImages.jl:1
in expression starting at C:\Users\densb\AppData\Local\Temp\jl_5XxI3XTk6d:37
ERROR: failed process: Process(`'C:\Users\densb\.julia\juliaup\julia-1.6.2+0~x64\bin\julia.exe' --color=yes --startup-file=no --cpu-target=native -O3 '--sysimage=C:\Users\densb\.julia\juliaup\julia-1.6.2+0~x64\lib\julia\sys.dll' '--project=C:\Users\densb\.julia\environments\v1.6' '--output-o=C:\Users\densb\AppData\Local\Temp\jl_v8HsukVhqC.o' 'C:\Users\densb\AppData\Local\Temp\jl_5XxI3XTk6d'`, ProcessExited(1)) [1]

Stacktrace:
  [1] pipeline_error
    @ .\process.jl:525 [inlined]
  [2] run(::Cmd; wait::Bool)
    @ Base .\process.jl:440
  [3] run
    @ .\process.jl:438 [inlined]
  [4] create_sysimg_object_file(object_file::String, packages::Vector{String}, packages_sysimg::Set{Base.PkgId}; project::String, base_sysimage::String, precompile_execution_file::Vector{String}, precompile_statements_file::Vector{String}, cpu_target::String, script::Nothing, isapp::Bool, sysimage_build_args::Cmd)
    @ PackageCompiler C:\Users\densb\.julia\packages\PackageCompiler\wpeto\src\PackageCompiler.jl:417
  [5] create_sysimage(packages::Vector{Symbol}; sysimage_path::String, project::String, precompile_execution_file::String, precompile_statements_file::Vector{String}, incremental::Bool, filter_stdlibs::Bool, replace_default::Bool, cpu_target::String, script::Nothing, sysimage_build_args::Cmd, include_transitive_dependencies::Bool, base_sysimage::Nothing, isapp::Bool, julia_init_c_file::Nothing, version::Nothing, compat_level::String, soname::Nothing)
    @ PackageCompiler C:\Users\densb\.julia\packages\PackageCompiler\wpeto\src\PackageCompiler.jl:619
  [6] top-level scope
    @ C:\Users\densb\.julia\config\startup.jl:38
  [7] eval
    @ .\boot.jl:360 [inlined]
  [8] eval
    @ .\client.jl:446 [inlined]
  [9] generate_my_sysimage()
    @ Main C:\Users\densb\.julia\config\startup.jl:43
 [10] top-level scope
    @ REPL[1]:1

(@v1.6) pkg> status PackageCompiler
      Status `C:\Users\densb\.julia\environments\v1.6\Project.toml`
  [9b87118b] PackageCompiler v1.7.6

(@v1.6) pkg> status
      Status `C:\Users\densb\.julia\environments\v1.6\Project.toml`
  [336ed68f] CSV v0.9.10
  [13f3f980] CairoMakie v0.6.6
  [e5143800] CircuitComponentRounding v0.3.3
  [39db22c5] ClipData v0.2.0
  [5ae59095] Colors v0.12.8
  [861a8166] Combinatorics v1.0.2
  [717857b8] DSP v0.7.3
  [a93c6f00] DataFrames v1.2.2
  [31c24e10] Distributions v0.25.23
  [7b398af1] ESeriesRounding v0.1.1
  [7a1cc6ca] FFTW v1.4.5
  [5789e2e9] FileIO v1.11.1
  [587475ba] Flux v0.12.8
  [e9467ef8] GLMakie v0.4.7
  [09f84164] HypothesisTests v0.10.4
  [6db54171] ImageClipboard v0.1.2
  [2b14c160] ImageEdgeDetection v0.1.4
  [916415d5] Images v0.24.1
  [d0351b0e] InspectDR v0.4.3
  [a98d9a8b] Interpolations v0.13.4
  [d1acc4aa] IntervalArithmetic v0.20.0
  [d2bf35a9] IntervalRootFinding v0.5.10
  [b964fa9f] LaTeXStrings v1.2.1
  [23fbe1c1] Latexify v0.15.9
  [2fda8390] LsqFit v0.12.1
  [23992714] MAT v0.10.1
  [10e44e05] MATLAB v0.8.2
  [ee78f7c6] Makie v0.15.3
  [eff96d63] Measurements v2.6.0
  [961ee093] ModelingToolkit v6.7.1
  [e94cdb99] MosaicViews v0.3.3
  [6c575b1c] NumericIO v0.3.2
  [6fe1bfb0] OffsetArrays v1.10.7
  [9b87118b] PackageCompiler v1.7.6
  [18e31ff7] Peaks v0.3.2
  [14b8a8f1] PkgTemplates v0.7.22
  [91a5bcdd] Plots v1.23.1
  [c3e4b0f8] Pluto v0.17.0
  [7f904dfe] PlutoUI v0.7.16
  [f27b6e38] Polynomials v2.0.17
  [08abe8d2] PrettyTables v1.2.3
  [d330b81b] PyPlot v2.10.0
  [3cdcf5f2] RecipesBase v1.1.2
  [d77cfa7a] RetroCap v2.0.0
  [295af30f] Revise v3.1.20
  [f2b01f46] Roots v1.3.5
  [2913bbd2] StatsBase v0.33.12
  [0c5d862f] Symbolics v3.5.1
  [3d876f86] TableScraper v0.1.3
  [bd369af6] Tables v1.6.0
  [c544e3c2] Tau v0.2.0
  [6aa5eb33] TaylorSeries v0.11.2
  [5e47fb64] TestImages v1.6.2
  [592b5752] Trapz v2.0.3
  [02ec7d09] Ueauty v0.1.0
  [1986cc42] Unitful v1.9.1
  [42071c24] UnitfulRecipes v1.5.0
  [8149f6b0] WAV v1.1.1
  [276b4fcb] WGLMakie v0.4.7
  [fdbf4ff8] XLSX v0.7.8
  [9a3f8284] Random

julia> versioninfo()
Julia Version 1.6.2
Commit 1b93d53fc4 (2021-07-14 15:36 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)

```

Should not be terribly relevant, but for completeness, here is the function I use to generate my sysimage:

```julia
function generate_my_sysimage()
    time_i = time()
    command = quote
        using PackageCompiler
        using Pkg
        Pkg.update()
        create_sysimage([:Unitful, :Measurements, :GLMakie, :WGLMakie, :CairoMakie, :CSV, :DataFrames, :Tau, :Random],
        sysimage_path = "C:/Users/densb/.julia/environments/v1.6/JuliaSysimage.dll",
            precompile_execution_file = "C:/Users/densb/GeekyStuff/Julia/sysimage/stuff_to_precompile.jl"
        )
    end
    eval(command)
    println("Time elapsed [minutes]: $((time()-time_i)/60).\nYou may close this program.")
end

```

---

<div class="post-metadata">

**Author:** ![Alessio\_Bellisomi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alessio_bellisomi/32/12525_2.png) [@Alessio\_Bellisomi](https://discourse.julialang.org/u/Alessio_Bellisomi)\
**Post date:** [December 23, 2021, 8:17pm UTC](https://discourse.julialang.org/t/assertionerror-0-tid-length-thread-rngs-during-compilation-with-packagecompiler/69179/17 "2021-12-23T20:17:58Z")

</div>

In my scenario, I was using the `Random` library in the main module. Once I removed it (pushed to another module) all went fine.
