Julia crashes without reporting anything when I optimize a vector of models in parallel

Edit: seems from Gurobi:

0.16759896278381348 secPRIVATE0000000000b8ff08 at /home/myuseer/.julia/artifacts/11980007f4c80fcdcbdd8e7b8dafaa8657dcead9/lib/libgurobi120.so (unknown line)
PRIVATE00000000006c0876 at /home/myuseer/.julia/artifacts/11980007f4c80fcdcbdd8e7b8dafaa8657dcead9/lib/libgurobi120.so (unknown line)
PRIVATE00000000005bf640 at /home/myuseer/.julia/artifacts/11980007f4c80fcdcbdd8e7b8dafaa8657dcead9/lib/libgurobi120.so (unknown line)
PRIVATE00000000000873bf at /home/myuseer/.julia/artifacts/11980007f4c80fcdcbdd8e7b8dafaa8657dcead9/lib/libgurobi120.so (unknown line)
PRIVATE00000000000eb367 at /home/myuseer/.julia/artifacts/11980007f4c80fcdcbdd8e7b8dafaa8657dcead9/lib/libgurobi120.so (unknown line)
GRBupdatemodel at /home/myuseer/.julia/artifacts/11980007f4c80fcdcbdd8e7b8dafaa8657dcead9/lib/libgurobi120.so (unknown line)
GRBupdatemodel at /home/myuseer/.julia/packages/Gurobi/PWFKA/src/gen120/libgrb_api.jl:2403 [inlined]
#_update_if_necessary#16 at /home/myuseer/.julia/packages/Gurobi/PWFKA/src/MOI_wrapper/MOI_wrapper.jl:603
_update_if_necessary at /home/myuseer/.julia/packages/Gurobi/PWFKA/src/MOI_wrapper/MOI_wrapper.jl:575 [inlined]
optimize! at /home/myuseer/.julia/packages/Gurobi/PWFKA/src/MOI_wrapper/MOI_wrapper.jl:2793
jfptr_optimizeNOT._4464 at /home/myuseer/.julia/compiled/v1.12/Gurobi/do9v6_CuD75.so (unknown line)
#optimize!#96 at /home/myuseer/.julia/packages/JuMP/N7h14/src/optimizer_interface.jl:609
optimize! at /home/myuseer/.julia/packages/JuMP/N7h14/src/optimizer_interface.jl:560 [inlined]
#subproblemˈs_duty#35 at ./REPL[38]:6
subproblemˈs_duty at ./REPL[38]:1
unknown function (ip: 0x7540740834f9) at (unknown file)
#70 at ./REPL[66]:18
unknown function (ip: 0x75407408343f) at (unknown file)
jl_apply at /cache/build/tester-amdci4-14/julialang/julia-release-1-dot-12/src/julia.h:2391 [inlined]
start_task at /cache/build/tester-amdci4-14/julialang/julia-release-1-dot-12/src/task.c:1249
Allocations: 31202495 (Pool: 31200091; Big: 2404); GC: 18
[1]    1464722 IOT instruction  julia

It appears that there is something wrong with this logic

            if istaskdone(tasks[j])
                wait(tasks[j])
                println("------ j = $j ------")
                tasks[j] = Threads.@spawn(subproblemˈs_duty(j; update_snap = true)) # schedule a new one
            end

I don’t know where it is wrong but it appears the issue is here.
It reports Gurobi Error 10017: Attempted to access a model while optimization is in progress.

But I wait the last task to be done, and only after then, re-spawn a new optimization task (i.e. via subproblem’s_duty).

This image suffices to exhibit what happens

Sorry, it seems again is a scope trap.

This is wrong:

tasks[j] = Threads.@spawn(subproblemˈs_duty(j; update_snap = true))

To fix, I need to write

tasks[j] = Threads.@spawn(subproblemˈs_duty($j; update_snap = true))