If the major GC is in Phase_idle, caml_gc_major_slice must start a new

major GC cycle instead of just calling caml_major_collection_slice.
fixes #7813
master
Damien Doligez 2020-10-02 18:33:57 +02:00
parent 2339a8c907
commit dff48afa72
3 changed files with 16 additions and 1 deletions

View File

@ -543,6 +543,9 @@ OCaml 4.12.0
- #7538, #9669: Check for misplaced attributes on module aliases
(Leo White, report by Thomas Leonard, review by Florian Angeletti)
- #7813, #9955: make sure the major GC cycle doesn't get stuck in Idle state
(Damien Doligez, report by Anders Fugmann, review by Jacques-Henri Jourdan)
- #7902, #9556: Type-checker infers recursive type, even though -rectypes is
off.
(Jacques Garrigue, report by Francois Pottier, review by Leo White)

View File

@ -603,10 +603,21 @@ cleanup:
CAMLprim value caml_gc_major_slice (value v)
{
value exn = Val_unit;
CAML_EV_BEGIN(EV_EXPLICIT_GC_MAJOR_SLICE);
CAMLassert (Is_long (v));
caml_major_collection_slice (Long_val (v));
if (caml_gc_phase == Phase_idle){
/* We need to start a new major GC cycle. Go through the pending_action
machinery. */
caml_request_major_slice ();
exn = caml_process_pending_actions_exn ();
/* Calls the major GC without passing [v] but the initial slice
ignores this parameter anyway. */
}else{
caml_major_collection_slice (Long_val (v));
}
CAML_EV_END(EV_EXPLICIT_GC_MAJOR_SLICE);
caml_raise_if_exception (exn);
return Val_long (0);
}

View File

@ -469,6 +469,7 @@ void caml_gc_dispatch (void)
/* The minor heap is full, we must do a minor collection. */
Caml_state->requested_minor_gc = 1;
}else{
/* The minor heap is half-full, do a major GC slice. */
Caml_state->requested_major_slice = 1;
}
if (caml_gc_phase == Phase_idle){