Skip to content

Commit 7b2e433

Browse files
vtjnashKristofferC
authored andcommitted
ensure bindings handle write barriers for ty and globalref (#47580)
This has probably been wrong for a long time (since being introduced in 7908246). (cherry picked from commit b369511)
1 parent e51f732 commit 7b2e433

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/gc.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3045,8 +3045,17 @@ static void jl_gc_queue_remset(jl_gc_mark_cache_t *gc_cache, jl_gc_mark_sp_t *sp
30453045
jl_binding_t *ptr = (jl_binding_t*)items[i];
30463046
// A null pointer can happen here when the binding is cleaned up
30473047
// as an exception is thrown after it was already queued (#10221)
3048+
int bnd_refyoung = 0;
30483049
jl_value_t *v = jl_atomic_load_relaxed(&ptr->value);
3049-
if (v != NULL && gc_mark_queue_obj(gc_cache, sp, v)) {
3050+
if (v != NULL && gc_mark_queue_obj(gc_cache, sp, v))
3051+
bnd_refyoung = 1;
3052+
jl_value_t *ty = jl_atomic_load_relaxed(&ptr->ty);
3053+
if (ty != NULL && gc_mark_queue_obj(gc_cache, sp, ty))
3054+
bnd_refyoung = 1;
3055+
jl_value_t *globalref = jl_atomic_load_relaxed(&ptr->globalref);
3056+
if (globalref != NULL && gc_mark_queue_obj(gc_cache, sp, globalref))
3057+
bnd_refyoung = 1;
3058+
if (bnd_refyoung) {
30503059
items[n_bnd_refyoung] = ptr;
30513060
n_bnd_refyoung++;
30523061
}

src/module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ JL_DLLEXPORT jl_value_t *jl_module_globalref(jl_module_t *m, jl_sym_t *var)
419419
if (jl_atomic_cmpswap_relaxed(&b->globalref, &globalref, newref)) {
420420
JL_GC_PROMISE_ROOTED(newref);
421421
globalref = newref;
422-
jl_gc_wb(m, globalref);
422+
jl_gc_wb_binding(b, globalref);
423423
}
424424
}
425425
JL_UNLOCK(&m->lock); // may GC

0 commit comments

Comments
 (0)