Skip to content

Commit

Permalink
ensure bindings handle write barriers for ty and globalref (#47580)
Browse files Browse the repository at this point in the history
This has probably been wrong for a long time (since being introduced in 7908246).

(cherry picked from commit b369511)
  • Loading branch information
vtjnash authored and KristofferC committed Dec 14, 2022
1 parent e51f732 commit 7b2e433
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3045,8 +3045,17 @@ static void jl_gc_queue_remset(jl_gc_mark_cache_t *gc_cache, jl_gc_mark_sp_t *sp
jl_binding_t *ptr = (jl_binding_t*)items[i];
// A null pointer can happen here when the binding is cleaned up
// as an exception is thrown after it was already queued (#10221)
int bnd_refyoung = 0;
jl_value_t *v = jl_atomic_load_relaxed(&ptr->value);
if (v != NULL && gc_mark_queue_obj(gc_cache, sp, v)) {
if (v != NULL && gc_mark_queue_obj(gc_cache, sp, v))
bnd_refyoung = 1;
jl_value_t *ty = jl_atomic_load_relaxed(&ptr->ty);
if (ty != NULL && gc_mark_queue_obj(gc_cache, sp, ty))
bnd_refyoung = 1;
jl_value_t *globalref = jl_atomic_load_relaxed(&ptr->globalref);
if (globalref != NULL && gc_mark_queue_obj(gc_cache, sp, globalref))
bnd_refyoung = 1;
if (bnd_refyoung) {
items[n_bnd_refyoung] = ptr;
n_bnd_refyoung++;
}
Expand Down
2 changes: 1 addition & 1 deletion src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ JL_DLLEXPORT jl_value_t *jl_module_globalref(jl_module_t *m, jl_sym_t *var)
if (jl_atomic_cmpswap_relaxed(&b->globalref, &globalref, newref)) {
JL_GC_PROMISE_ROOTED(newref);
globalref = newref;
jl_gc_wb(m, globalref);
jl_gc_wb_binding(b, globalref);
}
}
JL_UNLOCK(&m->lock); // may GC
Expand Down

0 comments on commit 7b2e433

Please sign in to comment.