Skip to content

Commit

Permalink
more friendly/useful error for stack overflow in type inference (#44971)
Browse files Browse the repository at this point in the history
fixes #44852

(cherry picked from commit 401d578)
  • Loading branch information
JeffBezanson authored and KristofferC committed Jul 20, 2022
1 parent 9bb9625 commit 6d7539b
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/gf.c
Expand Up @@ -319,10 +319,19 @@ jl_code_info_t *jl_type_infer(jl_method_instance_t *mi, size_t world, int force)
src = (jl_code_info_t*)jl_apply(fargs, 3);
}
JL_CATCH {
jl_printf((JL_STREAM*)STDERR_FILENO, "Internal error: encountered unexpected error in runtime:\n");
jl_static_show((JL_STREAM*)STDERR_FILENO, jl_current_exception());
jl_printf((JL_STREAM*)STDERR_FILENO, "\n");
jlbacktrace(); // written to STDERR_FILENO
jl_value_t *e = jl_current_exception();
if (e == jl_stackovf_exception) {
jl_printf((JL_STREAM*)STDERR_FILENO, "Internal error: stack overflow in type inference of ");
jl_static_show_func_sig((JL_STREAM*)STDERR_FILENO, (jl_value_t*)mi->specTypes);
jl_printf((JL_STREAM*)STDERR_FILENO, ".\n");
jl_printf((JL_STREAM*)STDERR_FILENO, "This might be caused by recursion over very long tuples or argument lists.\n");
}
else {
jl_printf((JL_STREAM*)STDERR_FILENO, "Internal error: encountered unexpected error in runtime:\n");
jl_static_show((JL_STREAM*)STDERR_FILENO, e);
jl_printf((JL_STREAM*)STDERR_FILENO, "\n");
jlbacktrace(); // written to STDERR_FILENO
}
src = NULL;
}
ct->world_age = last_age;
Expand Down

0 comments on commit 6d7539b

Please sign in to comment.