Skip to content

Commit 90d2e9c

Browse files
committed
Add a missing GC root in constant declaration
As pointed out in #56224 (comment).
1 parent 7715cf2 commit 90d2e9c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/toplevel.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,13 +742,16 @@ static void jl_eval_errorf(jl_module_t *m, const char *filename, int lineno, con
742742

743743
JL_DLLEXPORT jl_binding_partition_t *jl_declare_constant_val2(jl_binding_t *b, jl_module_t *mod, jl_sym_t *var, jl_value_t *val, enum jl_partition_kind constant_kind)
744744
{
745+
JL_GC_PUSH1(&val);
745746
jl_binding_partition_t *bpart = jl_get_binding_partition(b, jl_current_task->world_age);
746747
jl_ptr_kind_union_t pku = jl_atomic_load_relaxed(&bpart->restriction);
747748
int did_warn = 0;
748749
while (1) {
749750
if (jl_bkind_is_some_constant(decode_restriction_kind(pku))) {
750-
if (!val)
751+
if (!val) {
752+
JL_GC_POP();
751753
return bpart;
754+
}
752755
jl_value_t *old = decode_restriction_value(pku);
753756
JL_GC_PROMISE_ROOTED(old);
754757
if (jl_egal(val, old))
@@ -778,6 +781,7 @@ JL_DLLEXPORT jl_binding_partition_t *jl_declare_constant_val2(jl_binding_t *b, j
778781
break;
779782
}
780783
}
784+
JL_GC_POP();
781785
return bpart;
782786
}
783787

0 commit comments

Comments
 (0)