Skip to content

Commit a2e92fb

Browse files
authored
Merge pull request #20215 from JuliaLang/yyc/gc/missing
Fix another missing gc root in subtype.c
2 parents f263b4a + 7b65db0 commit a2e92fb

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/subtype.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,12 +1063,16 @@ static jl_value_t *intersect_var(jl_tvar_t *b, jl_value_t *a, jl_stenv_t *e, int
10631063
if (bb->lb == bb->ub && jl_is_typevar(bb->lb))
10641064
return intersect(a, bb->ub, e, param);
10651065
jl_value_t *ub = R ? intersect_ufirst(a, bb->ub, e, d) : intersect_ufirst(bb->ub, a, e, d);
1066-
if (!subtype_in_env(bb->lb, a, e))
1066+
JL_GC_PUSH1(&ub);
1067+
if (!subtype_in_env(bb->lb, a, e)) {
1068+
JL_GC_POP();
10671069
return jl_bottom_type;
1070+
}
10681071
if (ub != (jl_value_t*)b) {
10691072
bb->ub = ub;
10701073
bb->lb = ub;
10711074
}
1075+
JL_GC_POP();
10721076
return ub;
10731077
}
10741078
else if (bb->constraintkind == 0) {
@@ -1088,10 +1092,14 @@ static jl_value_t *intersect_var(jl_tvar_t *b, jl_value_t *a, jl_stenv_t *e, int
10881092
}
10891093
else if (bb->concrete || bb->constraintkind == 1) {
10901094
jl_value_t *ub = R ? intersect_ufirst(a, bb->ub, e, d) : intersect_ufirst(bb->ub, a, e, d);
1091-
if (ub == jl_bottom_type || !subtype_in_env(bb->lb, a, e))
1095+
JL_GC_PUSH1(&ub);
1096+
if (ub == jl_bottom_type || !subtype_in_env(bb->lb, a, e)) {
1097+
JL_GC_POP();
10921098
return jl_bottom_type;
1099+
}
10931100
if (ub != (jl_value_t*)b)
10941101
bb->ub = ub;
1102+
JL_GC_POP();
10951103
return (jl_value_t*)b;
10961104
}
10971105
else if (bb->constraintkind == 2) {
@@ -1155,6 +1163,7 @@ static int var_occurs_invariant(jl_value_t *v, jl_tvar_t *var, int inv)
11551163
return 0;
11561164
}
11571165

1166+
// Caller might not have rooted `res`
11581167
static jl_value_t *finish_unionall(jl_value_t *res, jl_varbinding_t *vb, jl_stenv_t *e)
11591168
{
11601169
jl_value_t *varval = NULL, *root = NULL;
@@ -1272,6 +1281,7 @@ static jl_value_t *intersect_unionall_(jl_value_t *t, jl_unionall_t *u, jl_stenv
12721281
res = jl_bottom_type;
12731282
}
12741283
if (res != jl_bottom_type)
1284+
// res is rooted by callee
12751285
res = finish_unionall(res, vb, e);
12761286
JL_GC_POP();
12771287
return res;

0 commit comments

Comments
 (0)