Skip to content

Commit 226d6ac

Browse files
stedolanmshinwell
authored andcommitted
flambda-backend: Add some checks that the minor GC does not recurse (#1743)
1 parent f3e7c0a commit 226d6ac

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

otherlibs/systhreads/st_stubs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ static void memprof_ctx_iter(th_ctx_action f, void* data)
247247

248248
CAMLexport void caml_thread_save_runtime_state(void)
249249
{
250+
if (Caml_state->in_minor_collection)
251+
caml_fatal_error("Thread switch from inside minor GC");
250252
#ifdef NATIVE_CODE
251253
curr_thread->top_of_stack = Caml_state->top_of_stack;
252254
curr_thread->bottom_of_stack = Caml_state->bottom_of_stack;

runtime/minor_gc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,8 @@ void caml_empty_minor_heap (void)
417417
#endif
418418
if (caml_minor_gc_begin_hook != NULL) (*caml_minor_gc_begin_hook) ();
419419
prev_alloc_words = caml_allocated_words;
420+
if (Caml_state->in_minor_collection)
421+
caml_fatal_error("Minor GC triggered recursively");
420422
Caml_state->in_minor_collection = 1;
421423
caml_gc_message (0x02, "<");
422424
CAML_EV_BEGIN(EV_MINOR_LOCAL_ROOTS);

0 commit comments

Comments
 (0)