From 227cefd2097c0caa1a341d4a5180e67801dee8e2 Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Sat, 18 Aug 2018 21:05:40 -0400 Subject: [PATCH] Fix three missing gc roots in subtyping All found by static analysis. I'm hoping one of them might have been the cause of CI failures like this one: https://circleci.com/gh/JuliaLang/julia/33846?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link (cherry picked from commit 640fc09189ed513c9f168bee56c43b9245f2f615) --- src/subtype.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/subtype.c b/src/subtype.c index 6b566415ee273..6ecea1840559f 100644 --- a/src/subtype.c +++ b/src/subtype.c @@ -598,8 +598,9 @@ static jl_value_t *fix_inferred_var_bound(jl_tvar_t *var, jl_value_t *ty) { if (!jl_is_typevar(ty) && jl_has_free_typevars(ty)) { jl_value_t *ans = ty; - jl_array_t *vs = jl_find_free_typevars(ty); + jl_array_t *vs = NULL; JL_GC_PUSH2(&ans, &vs); + vs = jl_find_free_typevars(ty); int i; for (i = 0; i < jl_array_len(vs); i++) { ans = jl_type_unionall((jl_tvar_t*)jl_array_ptr_ref(vs, i), ans); @@ -630,7 +631,7 @@ static int subtype_unionall(jl_value_t *t, jl_unionall_t *u, jl_stenv_t *e, int8 btemp = btemp->prev; } jl_varbinding_t vb = { u->var, u->var->lb, u->var->ub, R, NULL, 0, 0, 0, 0, e->invdepth, 0, NULL, e->vars }; - JL_GC_PUSH3(&u, &vb.lb, &vb.ub); + JL_GC_PUSH4(&u, &vb.lb, &vb.ub, &vb.innervars); e->vars = &vb; int ans; if (R) { @@ -1731,7 +1732,9 @@ static int intersect_vararg_length(jl_value_t *v, ssize_t n, jl_stenv_t *e, int8 // only do the check if N is free in the tuple type's last parameter if (jl_is_typevar(N) && N != (jl_value_t*)va_p1 && N != (jl_value_t*)va_p2) { jl_value_t *len = jl_box_long(n); + JL_GC_PUSH1(&len); jl_value_t *il = R ? intersect(len, N, e, 2) : intersect(N, len, e, 2); + JL_GC_POP(); if (il == jl_bottom_type) return 0; }