How to debug internal runtime error?

Can anyone point me to how to find the source of a runtime error? Meaning, is there some tool I can use to interrogate this, like I would with @code_typed or a debugger, if it weren’t a runtime error?

I’m struggling to pin this one down enough to make an MWE.

The final non-inference line in the stack trace is the first line of the below function, but that function is widely used, so I don’t really see how that line could be causing the problem. Indeed, when I call that same function in the REPL, no error. Similarly, when I pull the offending line out of with_theme to be called in the same context as the original error, but just before I call with_theme (so Makie.current_default_theme() returns the same), the error still isn’t triggered until inside with_theme.

Other than following the stack trace and trying to create the same circumstances (which I’ve done as far as I can see), I’m at a loss.

Offending function:

function with_theme(f, theme = Theme(); kwargs...)
    previous_theme = Makie.current_default_theme()   ## offending line
    try
        set_theme!(theme; kwargs...)
        f()
    catch e
        rethrow(e)
    finally
        set_theme!(previous_theme)
    end
end

Stack trace in v1.7

Internal error: encountered unexpected error in runtime:
TypeError(func=:<:, context="", expected=Type, got=P)
jl_type_error_rt at /buildworker/worker/package_linux64/build/src/rtutils.c:119
jl_type_error at /buildworker/worker/package_linux64/build/src/rtutils.c:127
jl_f_issubtype at /buildworker/worker/package_linux64/build/src/builtins.c:491
apply_type_nothrow at ./compiler/tfuncs.jl:1245
_builtin_nothrow at ./compiler/tfuncs.jl:1566
stmt_effect_free at ./compiler/ssair/queries.jl:36
check_effect_free! at ./compiler/ssair/inlining.jl:1128 [inlined]
process_simple! at ./compiler/ssair/inlining.jl:1185
assemble_inline_todo! at ./compiler/ssair/inlining.jl:1358
ssa_inlining_pass! at ./compiler/ssair/inlining.jl:80
jfptr_ssa_inlining_passNOT._9700.clone_1 at /home/graham/.local/opt/julia-1.7.0/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
run_passes at ./compiler/optimize.jl:307
optimize at ./compiler/optimize.jl:296 [inlined]
_typeinf at ./compiler/typeinfer.jl:255
typeinf at ./compiler/typeinfer.jl:209
typeinf_edge at ./compiler/typeinfer.jl:823 [inlined]
abstract_call_method at ./compiler/abstractinterpretation.jl:504
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:105
abstract_call_known at ./compiler/abstractinterpretation.jl:1342
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_call at ./compiler/abstractinterpretation.jl:1382
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1534
typeinf_local at ./compiler/abstractinterpretation.jl:1918
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2014
_typeinf at ./compiler/typeinfer.jl:226
typeinf at ./compiler/typeinfer.jl:209
typeinf_edge at ./compiler/typeinfer.jl:823 [inlined]
abstract_call_method at ./compiler/abstractinterpretation.jl:504
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:105
abstract_call_known at ./compiler/abstractinterpretation.jl:1342
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_call at ./compiler/abstractinterpretation.jl:1382
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1534
typeinf_local at ./compiler/abstractinterpretation.jl:1900
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2014
_typeinf at ./compiler/typeinfer.jl:226
typeinf at ./compiler/typeinfer.jl:209
typeinf_edge at ./compiler/typeinfer.jl:823 [inlined]
abstract_call_method at ./compiler/abstractinterpretation.jl:504
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:105
abstract_call_known at ./compiler/abstractinterpretation.jl:1342
abstract_call at ./compiler/abstractinterpretation.jl:1397
abstract_call at ./compiler/abstractinterpretation.jl:1382
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1534
typeinf_local at ./compiler/abstractinterpretation.jl:1900
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2014
_typeinf at ./compiler/typeinfer.jl:226
typeinf at ./compiler/typeinfer.jl:209
typeinf_edge at ./compiler/typeinfer.jl:823 [inlined]
abstract_call_method at ./compiler/abstractinterpretation.jl:504
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:105
abstract_call at ./compiler/abstractinterpretation.jl:1395
abstract_call at ./compiler/abstractinterpretation.jl:1382
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1534
typeinf_local at ./compiler/abstractinterpretation.jl:1900
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2014
_typeinf at ./compiler/typeinfer.jl:226
typeinf at ./compiler/typeinfer.jl:209
typeinf_ext at ./compiler/typeinfer.jl:909
typeinf_ext_toplevel at ./compiler/typeinfer.jl:942
typeinf_ext_toplevel at ./compiler/typeinfer.jl:938
jfptr_typeinf_ext_toplevel_9887.clone_1 at /home/graham/.local/opt/julia-1.7.0/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
jl_type_infer at /buildworker/worker/package_linux64/build/src/gf.c:295
jl_generate_fptr at /buildworker/worker/package_linux64/build/src/jitlayers.cpp:338
jl_compile_method_internal at /buildworker/worker/package_linux64/build/src/gf.c:1980
jl_compile_method_internal at /buildworker/worker/package_linux64/build/src/gf.c:2246 [inlined]
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2239 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
with_theme at /home/graham/.julia/packages/Makie/gQOQF/src/theming.jl:139
unknown function (ip: 0x7f763e23f8b1)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
#fig_5_nullclines_differing_failure#46 at /home/graham/git/FailureOfInhibition2021/scripts/fig_5_nullclines_differing_failure.jl:80
unknown function (ip: 0x7f763e2095f3)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
fig_5_nullclines_differing_failure##kw at /home/graham/git/FailureOfInhibition2021/scripts/fig_5_nullclines_differing_failure.jl:65
unknown function (ip: 0x7f763e1e015d)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:126
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:215
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:166 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:587
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:731
top-level scope at /home/graham/git/FailureOfInhibition2021/scripts/fig_5_nullclines_differing_failure.jl:117
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:885
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:830
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/toplevel.c:944
eval at ./boot.jl:373 [inlined]
include_string at ./loading.jl:1196
include_string at ./loading.jl:1206
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
jl_f__call_latest at /buildworker/worker/package_linux64/build/src/builtins.c:757
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
do_apply at /buildworker/worker/package_linux64/build/src/builtins.c:713
#invokelatest#2 at ./essentials.jl:716
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
do_apply at /buildworker/worker/package_linux64/build/src/builtins.c:713
invokelatest at ./essentials.jl:714
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
do_apply at /buildworker/worker/package_linux64/build/src/builtins.c:713
#inlineeval#65 at /home/graham/.vscode/extensions/julialang.language-julia-1.5.8/scripts/packages/VSCodeServer/src/eval.jl:211
inlineeval##kw at /home/graham/.vscode/extensions/julialang.language-julia-1.5.8/scripts/packages/VSCodeServer/src/eval.jl:209 [inlined]
#60 at /home/graham/.vscode/extensions/julialang.language-julia-1.5.8/scripts/packages/VSCodeServer/src/eval.jl:155
withpath at /home/graham/.vscode/extensions/julialang.language-julia-1.5.8/scripts/packages/VSCodeServer/src/repl.jl:185
#59 at /home/graham/.vscode/extensions/julialang.language-julia-1.5.8/scripts/packages/VSCodeServer/src/eval.jl:153
hideprompt at /home/graham/.vscode/extensions/julialang.language-julia-1.5.8/scripts/packages/VSCodeServer/src/repl.jl:36
#58 at /home/graham/.vscode/extensions/julialang.language-julia-1.5.8/scripts/packages/VSCodeServer/src/eval.jl:124
unknown function (ip: 0x7f769da3df8f)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
with_logstate at ./logging.jl:511
with_logger at ./logging.jl:623 [inlined]
#57 at /home/graham/.vscode/extensions/julialang.language-julia-1.5.8/scripts/packages/VSCodeServer/src/eval.jl:201
unknown function (ip: 0x7f769da3c20f)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
jl_f__call_latest at /buildworker/worker/package_linux64/build/src/builtins.c:757
#invokelatest#2 at ./essentials.jl:716 [inlined]
invokelatest at ./essentials.jl:714
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
do_apply at /buildworker/worker/package_linux64/build/src/builtins.c:713
macro expansion at /home/graham/.vscode/extensions/julialang.language-julia-1.5.8/scripts/packages/VSCodeServer/src/eval.jl:34 [inlined]
#55 at ./task.jl:423
unknown function (ip: 0x7f769d9fe0af)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
start_task at /buildworker/worker/package_linux64/build/src/task.c:877

Stack trace on master:

Internal error: encountered unexpected error in runtime:
TypeError(func=:<:, context="", expected=Type, got=P)
ijl_type_error_rt at /buildworker/worker/package_linux64/build/src/rtutils.c:119
ijl_type_error at /buildworker/worker/package_linux64/build/src/rtutils.c:127
jl_f_issubtype at /buildworker/worker/package_linux64/build/src/builtins.c:491
apply_type_nothrow at ./compiler/tfuncs.jl:1199
_builtin_nothrow at ./compiler/tfuncs.jl:1533
stmt_effect_free at ./compiler/optimize.jl:224
check_effect_free! at ./compiler/ssair/inlining.jl:1060 [inlined]
process_simple! at ./compiler/ssair/inlining.jl:1116
assemble_inline_todo! at ./compiler/ssair/inlining.jl:1290
ssa_inlining_pass! at ./compiler/ssair/inlining.jl:77
jfptr_ssa_inlining_passNOT._10138.clone_1 at /home/graham/.local/opt/julia-latest/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2304 [inlined]
ijl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2486
run_passes at ./compiler/optimize.jl:445
optimize at ./compiler/optimize.jl:436 [inlined]
_typeinf at ./compiler/typeinfer.jl:255
typeinf at ./compiler/typeinfer.jl:209
typeinf_edge at ./compiler/typeinfer.jl:826 [inlined]
abstract_call_method at ./compiler/abstractinterpretation.jl:570
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:117
abstract_call_known at ./compiler/abstractinterpretation.jl:1487
abstract_call at ./compiler/abstractinterpretation.jl:1543
abstract_call at ./compiler/abstractinterpretation.jl:1525
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1664
typeinf_local at ./compiler/abstractinterpretation.jl:2053
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2149
_typeinf at ./compiler/typeinfer.jl:226
typeinf at ./compiler/typeinfer.jl:209
typeinf_edge at ./compiler/typeinfer.jl:826 [inlined]
abstract_call_method at ./compiler/abstractinterpretation.jl:570
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:117
abstract_call_known at ./compiler/abstractinterpretation.jl:1487
abstract_call at ./compiler/abstractinterpretation.jl:1543
abstract_call at ./compiler/abstractinterpretation.jl:1525
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1664
typeinf_local at ./compiler/abstractinterpretation.jl:2033
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2149
_typeinf at ./compiler/typeinfer.jl:226
typeinf at ./compiler/typeinfer.jl:209
typeinf_edge at ./compiler/typeinfer.jl:826 [inlined]
abstract_call_method at ./compiler/abstractinterpretation.jl:570
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:117
abstract_call_known at ./compiler/abstractinterpretation.jl:1487
abstract_call at ./compiler/abstractinterpretation.jl:1543
abstract_call at ./compiler/abstractinterpretation.jl:1525
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1664
typeinf_local at ./compiler/abstractinterpretation.jl:2033
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2149
_typeinf at ./compiler/typeinfer.jl:226
typeinf at ./compiler/typeinfer.jl:209
typeinf_edge at ./compiler/typeinfer.jl:826 [inlined]
abstract_call_method at ./compiler/abstractinterpretation.jl:570
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:117
abstract_call at ./compiler/abstractinterpretation.jl:1541
abstract_call at ./compiler/abstractinterpretation.jl:1525
abstract_eval_statement at ./compiler/abstractinterpretation.jl:1664
typeinf_local at ./compiler/abstractinterpretation.jl:2033
typeinf_nocycle at ./compiler/abstractinterpretation.jl:2149
_typeinf at ./compiler/typeinfer.jl:226
typeinf at ./compiler/typeinfer.jl:209
typeinf_ext at ./compiler/typeinfer.jl:907
typeinf_ext_toplevel at ./compiler/typeinfer.jl:940
typeinf_ext_toplevel at ./compiler/typeinfer.jl:936
jfptr_typeinf_ext_toplevel_16897.clone_1 at /home/graham/.local/opt/julia-latest/lib/julia/sys.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2304 [inlined]
ijl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2486
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1789 [inlined]
jl_type_infer at /buildworker/worker/package_linux64/build/src/gf.c:295
jl_generate_fptr_impl at /buildworker/worker/package_linux64/build/src/jitlayers.cpp:301
jl_compile_method_internal at /buildworker/worker/package_linux64/build/src/gf.c:2020
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2296 [inlined]
ijl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2486
with_theme at /home/graham/.julia/packages/Makie/gQOQF/src/theming.jl:139
unknown function (ip: 0x7f833009bf61)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2304 [inlined]
ijl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2486
#fig_5_nullclines_differing_failure#46 at /home/graham/git/FailureOfInhibition2021/scripts/fig_5_nullclines_differing_failure.jl:80
unknown function (ip: 0x7f833005f893)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2304 [inlined]
ijl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2486
fig_5_nullclines_differing_failure##kw at /home/graham/git/FailureOfInhibition2021/scripts/fig_5_nullclines_differing_failure.jl:65
unknown function (ip: 0x7f83300371ad)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2304 [inlined]
ijl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2486
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1789 [inlined]
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:126
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:215
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:166 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:612
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:744
top-level scope at /home/graham/git/FailureOfInhibition2021/scripts/fig_5_nullclines_differing_failure.jl:117
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:888
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:832
ijl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/toplevel.c:947
eval at ./boot.jl:368 [inlined]
include_string at ./loading.jl:1251
include_string at ./loading.jl:1261
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2304 [inlined]
ijl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2486
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1789 [inlined]
jl_f__call_latest at /buildworker/worker/package_linux64/build/src/builtins.c:757
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2304 [inlined]
ijl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2486
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1789 [inlined]
do_apply at /buildworker/worker/package_linux64/build/src/builtins.c:713
#invokelatest#2 at ./essentials.jl:731
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2304 [inlined]
ijl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2486
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1789 [inlined]
do_apply at /buildworker/worker/package_linux64/build/src/builtins.c:713
invokelatest at ./essentials.jl:729
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2304 [inlined]
ijl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2486
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1789 [inlined]
do_apply at /buildworker/worker/package_linux64/build/src/builtins.c:713
#inlineeval#65 at /home/graham/.vscode/extensions/julialang.language-julia-1.5.8/scripts/packages/VSCodeServer/src/eval.jl:211
inlineeval##kw at /home/graham/.vscode/extensions/julialang.language-julia-1.5.8/scripts/packages/VSCodeServer/src/eval.jl:209 [inlined]
#60 at /home/graham/.vscode/extensions/julialang.language-julia-1.5.8/scripts/packages/VSCodeServer/src/eval.jl:155
withpath at /home/graham/.vscode/extensions/julialang.language-julia-1.5.8/scripts/packages/VSCodeServer/src/repl.jl:185
#59 at /home/graham/.vscode/extensions/julialang.language-julia-1.5.8/scripts/packages/VSCodeServer/src/eval.jl:153
hideprompt at /home/graham/.vscode/extensions/julialang.language-julia-1.5.8/scripts/packages/VSCodeServer/src/repl.jl:36
#58 at /home/graham/.vscode/extensions/julialang.language-julia-1.5.8/scripts/packages/VSCodeServer/src/eval.jl:124
unknown function (ip: 0x7f834461ea2f)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2304 [inlined]
ijl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2486
with_logstate at ./logging.jl:511
with_logger at ./logging.jl:623 [inlined]
#57 at /home/graham/.vscode/extensions/julialang.language-julia-1.5.8/scripts/packages/VSCodeServer/src/eval.jl:201
unknown function (ip: 0x7f834461ce2f)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2304 [inlined]
ijl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2486
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1789 [inlined]
jl_f__call_latest at /buildworker/worker/package_linux64/build/src/builtins.c:757
#invokelatest#2 at ./essentials.jl:731 [inlined]
invokelatest at ./essentials.jl:729
unknown function (ip: 0x7f8344615c32)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2304 [inlined]
ijl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2486
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1789 [inlined]
do_apply at /buildworker/worker/package_linux64/build/src/builtins.c:713
macro expansion at /home/graham/.vscode/extensions/julialang.language-julia-1.5.8/scripts/packages/VSCodeServer/src/eval.jl:34 [inlined]
#55 at ./task.jl:466
unknown function (ip: 0x7f83445968df)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2304 [inlined]
ijl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2486
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1789 [inlined]
start_task at /buildworker/worker/package_linux64/build/src/task.c:924

I’ve come to the maybe-obvious conclusion that the offending line is not actually the indicated one, but the following one, which involves the anonymous function f, and I’ve narrowed it down to which variable in which line of that anonymous function causes the error. That variable is itself a complicated anonymous function, so the search continues.

I also tried looking at the typed code of the call to with_theme (to see if code_typed would error, too) and get the error:

ERROR: LoadError: TypeError: in <:, expected Type, got a value of type TypeVar
Stacktrace:
  [1] apply_type_nothrow(argtypes::Vector{Any}, rt::Any)
    @ Core.Compiler ./compiler/tfuncs.jl:1199
  [2] _builtin_nothrow(f::Any, argtypes::Vector{Any}, rt::Any)
    @ Core.Compiler ./compiler/tfuncs.jl:1533
  [3] stmt_effect_free(stmt::Any, rt::Any, src::Core.Compiler.IRCode)
    @ Core.Compiler ./compiler/optimize.jl:224
  [4] check_effect_free!
    @ ./compiler/ssair/inlining.jl:1060 [inlined]
  [5] process_simple!(ir::Core.Compiler.IRCode, idx::Int64, state::Core.Compiler.InliningState{Core.Compiler.EdgeTracker, Core.Compiler.WorldView{Core.Compiler.InternalCodeCache}, Core.Compiler.NativeInterpreter}, todo::Vector{Pair{Int64, Any}})
    @ Core.Compiler ./compiler/ssair/inlining.jl:1116
  [6] assemble_inline_todo!(ir::Core.Compiler.IRCode, state::Core.Compiler.InliningState{Core.Compiler.EdgeTracker, Core.Compiler.WorldView{Core.Compiler.InternalCodeCache}, Core.Compiler.NativeInterpreter})
    @ Core.Compiler ./compiler/ssair/inlining.jl:1290
  [7] ssa_inlining_pass!(ir::Core.Compiler.IRCode, linetable::Vector{Core.LineInfoNode}, state::Core.Compiler.InliningState{Core.Compiler.EdgeTracker, Core.Compiler.WorldView{Core.Compiler.InternalCodeCache}, Core.Compiler.NativeInterpreter}, propagate_inbounds::Bool)
    @ Core.Compiler ./compiler/ssair/inlining.jl:77
  [8] run_passes(ci::Core.CodeInfo, sv::Core.Compiler.OptimizationState)
    @ Core.Compiler ./compiler/optimize.jl:445
  [9] optimize
    @ ./compiler/optimize.jl:436 [inlined]
 [10] _typeinf(interp::Core.Compiler.NativeInterpreter, frame::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/typeinfer.jl:255
 [11] typeinf(interp::Core.Compiler.NativeInterpreter, frame::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/typeinfer.jl:209
 [12] typeinf_edge
    @ ./compiler/typeinfer.jl:826 [inlined]
 [13] abstract_call_method(interp::Core.Compiler.NativeInterpreter, method::Method, sig::Any, sparams::Core.SimpleVector, hardlimit::Bool, sv::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:570
 [14] abstract_call_gf_by_type(interp::Core.Compiler.NativeInterpreter, f::Any, arginfo::Core.Compiler.ArgInfo, atype::Any, sv::Core.Compiler.InferenceState, max_methods::Int64)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:117
 [15] abstract_call_known(interp::Core.Compiler.NativeInterpreter, f::Any, arginfo::Core.Compiler.ArgInfo, sv::Core.Compiler.InferenceState, max_methods::Int64)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:1487
 [16] abstract_call(interp::Core.Compiler.NativeInterpreter, arginfo::Core.Compiler.ArgInfo, sv::Core.Compiler.InferenceState, max_methods::Int64)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:1543
 [17] abstract_call(interp::Core.Compiler.NativeInterpreter, arginfo::Core.Compiler.ArgInfo, sv::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:1525
 [18] abstract_eval_statement(interp::Core.Compiler.NativeInterpreter, e::Any, vtypes::Vector{Core.Compiler.VarState}, sv::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:1664
 [19] typeinf_local(interp::Core.Compiler.NativeInterpreter, frame::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:2053
 [20] typeinf_nocycle(interp::Core.Compiler.NativeInterpreter, frame::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:2149
 [21] _typeinf(interp::Core.Compiler.NativeInterpreter, frame::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/typeinfer.jl:226
 [22] typeinf(interp::Core.Compiler.NativeInterpreter, frame::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/typeinfer.jl:209
 [23] typeinf_edge
    @ ./compiler/typeinfer.jl:826 [inlined]
 [24] abstract_call_method(interp::Core.Compiler.NativeInterpreter, method::Method, sig::Any, sparams::Core.SimpleVector, hardlimit::Bool, sv::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:570
 [25] abstract_call_gf_by_type(interp::Core.Compiler.NativeInterpreter, f::Any, arginfo::Core.Compiler.ArgInfo, atype::Any, sv::Core.Compiler.InferenceState, max_methods::Int64)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:117
 [26] abstract_call_known(interp::Core.Compiler.NativeInterpreter, f::Any, arginfo::Core.Compiler.ArgInfo, sv::Core.Compiler.InferenceState, max_methods::Int64)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:1487
 [27] abstract_call(interp::Core.Compiler.NativeInterpreter, arginfo::Core.Compiler.ArgInfo, sv::Core.Compiler.InferenceState, max_methods::Int64)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:1543
 [28] abstract_call(interp::Core.Compiler.NativeInterpreter, arginfo::Core.Compiler.ArgInfo, sv::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:1525
 [29] abstract_eval_statement(interp::Core.Compiler.NativeInterpreter, e::Any, vtypes::Vector{Core.Compiler.VarState}, sv::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:1664
 [30] typeinf_local(interp::Core.Compiler.NativeInterpreter, frame::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:2033
--- the last 11 lines are repeated 1 more time ---
 [42] typeinf_nocycle(interp::Core.Compiler.NativeInterpreter, frame::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:2149
 [43] _typeinf(interp::Core.Compiler.NativeInterpreter, frame::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/typeinfer.jl:226
 [44] typeinf(interp::Core.Compiler.NativeInterpreter, frame::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/typeinfer.jl:209
 [45] typeinf_edge
    @ ./compiler/typeinfer.jl:826 [inlined]
 [46] abstract_call_method(interp::Core.Compiler.NativeInterpreter, method::Method, sig::Any, sparams::Core.SimpleVector, hardlimit::Bool, sv::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:570
 [47] abstract_call_gf_by_type(interp::Core.Compiler.NativeInterpreter, f::Any, arginfo::Core.Compiler.ArgInfo, atype::Any, sv::Core.Compiler.InferenceState, max_methods::Int64)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:117
 [48] abstract_call(interp::Core.Compiler.NativeInterpreter, arginfo::Core.Compiler.ArgInfo, sv::Core.Compiler.InferenceState, max_methods::Int64)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:1541
 [49] abstract_call(interp::Core.Compiler.NativeInterpreter, arginfo::Core.Compiler.ArgInfo, sv::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:1525
 [50] abstract_eval_statement(interp::Core.Compiler.NativeInterpreter, e::Any, vtypes::Vector{Core.Compiler.VarState}, sv::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:1664
 [51] typeinf_local(interp::Core.Compiler.NativeInterpreter, frame::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:2033
 [52] typeinf_nocycle(interp::Core.Compiler.NativeInterpreter, frame::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:2149
 [53] _typeinf(interp::Core.Compiler.NativeInterpreter, frame::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/typeinfer.jl:226
 [54] typeinf(interp::Core.Compiler.NativeInterpreter, frame::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/typeinfer.jl:209
 [55] typeinf_edge
    @ ./compiler/typeinfer.jl:826 [inlined]
 [56] abstract_call_method(interp::Core.Compiler.NativeInterpreter, method::Method, sig::Any, sparams::Core.SimpleVector, hardlimit::Bool, sv::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:570
 [57] abstract_call_gf_by_type(interp::Core.Compiler.NativeInterpreter, f::Any, arginfo::Core.Compiler.ArgInfo, atype::Any, sv::Core.Compiler.InferenceState, max_methods::Int64)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:117
 [58] abstract_call_known(interp::Core.Compiler.NativeInterpreter, f::Any, arginfo::Core.Compiler.ArgInfo, sv::Core.Compiler.InferenceState, max_methods::Int64)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:1487
 [59] abstract_call(interp::Core.Compiler.NativeInterpreter, arginfo::Core.Compiler.ArgInfo, sv::Core.Compiler.InferenceState, max_methods::Int64)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:1543
 [60] abstract_call(interp::Core.Compiler.NativeInterpreter, arginfo::Core.Compiler.ArgInfo, sv::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:1525
 [61] abstract_eval_statement(interp::Core.Compiler.NativeInterpreter, e::Any, vtypes::Vector{Core.Compiler.VarState}, sv::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:1664
 [62] typeinf_local(interp::Core.Compiler.NativeInterpreter, frame::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:2053
 [63] typeinf_nocycle(interp::Core.Compiler.NativeInterpreter, frame::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/abstractinterpretation.jl:2149
 [64] _typeinf(interp::Core.Compiler.NativeInterpreter, frame::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/typeinfer.jl:226
 [65] typeinf(interp::Core.Compiler.NativeInterpreter, frame::Core.Compiler.InferenceState)
    @ Core.Compiler ./compiler/typeinfer.jl:209
 [66] typeinf_code(interp::Core.Compiler.NativeInterpreter, method::Method, atype::Any, sparams::Core.SimpleVector, run_optimizer::Bool)
    @ Core.Compiler ./compiler/typeinfer.jl:848
 [67] code_typed_by_type(tt::Any; optimize::Bool, debuginfo::Symbol, world::UInt64, interp::Core.Compiler.NativeInterpreter)
    @ Base ./reflection.jl:1248
 [68] code_typed(f::Any, types::Any; optimize::Bool, debuginfo::Symbol, world::UInt64, interp::Core.Compiler.NativeInterpreter)
    @ Base ./reflection.jl:1204
 [69] code_typed
    @ ./reflection.jl:1191 [inlined]
 [70] macro expansion
    @ ~/.local/opt/julia-latest/share/julia/stdlib/v1.8/InteractiveUtils/src/macros.jl:222 [inlined]
 [71] fig_5_nullclines_differing_failure(; mods::NamedTuple{(:τ, :α, :aE, :firing_aI, :blocking_aI, :θE, :firing_θI, :blocking_θI), Tuple{Tuple{Float64, Float64}, Tuple{Float64, Float64}, Float64, Float64, Float64, Float64, Float64, Float64}}, saved_lb::Float64, saved_ub::Float64, saved_len::Int64, session_name::String, subset_range::IntervalSets.ClosedInterval{Float64}, name_mapping::Dict{Any, Function}, blocking_data::NamedTuple{(:fp_arr, :fp_axes, :nullcline_mods, :prototype_name), Tuple{NamedDimsArray{(:Aee, :Aei, :Aie, :Aii), Vector{Vector{Float64}}, 4, Array{Vector{Vector{Float64}}, 4}}, NamedTuple{(:Aee, :Aei, :Aie, :Aii), NTuple{4, Vector{Float64}}}, NamedTuple{(:n_lattice, :save_idxs, :save_on, :saveat, :τ, :α, :aE, :firing_aI, :blocking_aI, :θE, :firing_θI, :blocking_θI), Tuple{Int64, Nothing, Bool, Float64, Tuple{Float64, Float64}, Tuple{Float64, Float64}, Float64, Float64, Float64, Float64, Float64, Float64}}, String}}, monotonic_data::NamedTuple{(:fp_arr, :fp_axes, :nullcline_mods, :prototype_name), Tuple{NamedDimsArray{(:Aee, :Aei, :Aie, :Aii), Vector{Vector{Float64}}, 4, Array{Vector{Vector{Float64}}, 4}}, NamedTuple{(:Aee, :Aei, :Aie, :Aii), NTuple{4, Vector{Float64}}}, NamedTuple{(:n_lattice, :save_idxs, :save_on, :saveat, :τ, :α, :aE, :firing_aI, :blocking_aI, :θE, :firing_θI, :blocking_θI), Tuple{Int64, Nothing, Bool, Float64, Tuple{Float64, Float64}, Tuple{Float64, Float64}, Float64, Float64, Float64, Float64, Float64, Float64}}, String}}, blocking_fp_arr::NamedDimsArray{(:Aee, :Aei, :Aie, :Aii), Vector{Vector{Float64}}, 4, Array{Vector{Vector{Float64}}, 4}}, blocking_fp_axes::NamedTuple{(:Aee, :Aei, :Aie, :Aii), NTuple{4, Vector{Float64}}}, blocking_prototype_name::String, monotonic_fp_arr::NamedDimsArray{(:Aee, :Aei, :Aie, :Aii), Vector{Vector{Float64}}, 4, Array{Vector{Vector{Float64}}, 4}}, monotonic_fp_axes::NamedTuple{(:Aee, :Aei, :Aie, :Aii), NTuple{4, Vector{Float64}}}, monotonic_prototype_name::String, fp_axes_nt::Dict{Symbol, NamedTuple{(:Aee, :Aei, :Aie, :Aii), NTuple{4, Vector{Float64}}}}, fp_arr_nt::Dict{Symbol, NamedDimsArray{(:Aee, :Aei, :Aie, :Aii), Vector{Vector{Float64}}, 4, Array{Vector{Vector{Float64}}, 4}}}, nonl_types::Tuple{Symbol, Symbol}, prototype_name_nt::Dict{Symbol, String}, arrows_step::Float64, session_id::String, axis::NamedTuple{(:width, :height), Tuple{Int64, Int64}}, plots_subdir::String)
    @ Main ~/git/FailureOfInhibition2021/scripts/fig_5_nullclines_differing_failure.jl:80
in expression starting at /home/graham/git/FailureOfInhibition2021/scripts/fig_5_nullclines_differing_failure.jl:107

Try Debugger.jl: @enter, you can execute it in a single step and see if it continues to trigger errors.

https://github.com/JuliaDebug/Debugger.jl

The way I understand to use Debugger, I don’t think that will work, since the error is occurring in the runtime compiler. To get the error to happen, I would need to enter compiled mode, but then I wouldn’t be able to stop right before the error either.

Maybe @aviatesk has an idea (since he has been working on the optimizer recently)?