Skip to content

Commit

Permalink
flambda-backend: Add some checks that the minor GC does not recurse (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
stedolan authored and mshinwell committed Aug 16, 2023
1 parent f3e7c0a commit 226d6ac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions otherlibs/systhreads/st_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ static void memprof_ctx_iter(th_ctx_action f, void* data)

CAMLexport void caml_thread_save_runtime_state(void)
{
if (Caml_state->in_minor_collection)
caml_fatal_error("Thread switch from inside minor GC");
#ifdef NATIVE_CODE
curr_thread->top_of_stack = Caml_state->top_of_stack;
curr_thread->bottom_of_stack = Caml_state->bottom_of_stack;
Expand Down
2 changes: 2 additions & 0 deletions runtime/minor_gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ void caml_empty_minor_heap (void)
#endif
if (caml_minor_gc_begin_hook != NULL) (*caml_minor_gc_begin_hook) ();
prev_alloc_words = caml_allocated_words;
if (Caml_state->in_minor_collection)
caml_fatal_error("Minor GC triggered recursively");
Caml_state->in_minor_collection = 1;
caml_gc_message (0x02, "<");
CAML_EV_BEGIN(EV_MINOR_LOCAL_ROOTS);
Expand Down

0 comments on commit 226d6ac

Please sign in to comment.