From 0323edf99d5d342153bb71d2fe56d5a17c154717 Mon Sep 17 00:00:00 2001 From: Nick Barnes Date: Thu, 21 Nov 2024 19:10:48 +0000 Subject: [PATCH] Fix ephemeron-adoption problem found when upstreaming mark-delay to ocaml/ocaml#13580. --- runtime/major_gc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/runtime/major_gc.c b/runtime/major_gc.c index 3db9c85908..a99c88ee2d 100644 --- a/runtime/major_gc.c +++ b/runtime/major_gc.c @@ -1431,13 +1431,14 @@ void caml_mark_roots_stw (int participant_count, caml_domain_state** barrier_par Caml_global_barrier_if_final(participant_count) { caml_gc_phase = Phase_sweep_and_mark_main; atomic_store_relaxed(&global_roots_scanned, WORK_UNSTARTED); + /* Adopt orphaned work from domains that were spawned and + terminated in the previous cycle. Do this in the barrier, + before any domain can terminate on this cycle. */ + adopt_orphaned_work (caml_global_heap_state.UNMARKED); } caml_domain_state* domain = Caml_state; - /* Adopt orphaned work from domains that were spawned and terminated in the - previous cycle. */ - adopt_orphaned_work (caml_global_heap_state.UNMARKED); begin_ephe_marking();