Skip to content

Commit d1f82c4

Browse files
authored
flambda-backend: Ensure the minor heap is actually empty before reallocating it (#2208)
1 parent 5eb9849 commit d1f82c4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

runtime/minor_gc.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,11 @@ void caml_set_minor_heap_size (asize_t wsize)
139139

140140
if (domain_state->young_ptr != domain_state->young_end) {
141141
CAML_EV_COUNTER (EV_C_FORCE_MINOR_SET_MINOR_HEAP_SIZE, 1);
142-
caml_minor_collection();
142+
// Don't call caml_minor_collection, since that can run the
143+
// caml_domain_external_interrupt_hook, which can allocate.
144+
caml_empty_minor_heaps_once();
143145
}
146+
CAMLassert (domain_state->young_ptr == domain_state->young_end);
144147

145148
if(caml_reallocate_minor_heap(wsize) < 0) {
146149
caml_fatal_error("Fatal error: No memory for minor heap");
@@ -759,7 +762,10 @@ caml_stw_empty_minor_heap_no_major_slice(caml_domain_state* domain,
759762
#endif
760763

761764
CAML_EV_END(EV_MINOR_CLEAR);
765+
762766
caml_gc_log("finished stw empty_minor_heap");
767+
CAMLassert(domain->young_ptr == domain->young_end);
768+
763769
Caml_state->in_minor_collection = 0;
764770
}
765771

0 commit comments

Comments
 (0)