diff --git a/runtime/caml/gc_ctrl.h b/runtime/caml/gc_ctrl.h index c56470b4f9..223bd50549 100644 --- a/runtime/caml/gc_ctrl.h +++ b/runtime/caml/gc_ctrl.h @@ -20,7 +20,7 @@ #include "misc.h" -CAMLextern uintnat caml_max_stack_wsize; +CAMLextern atomic_uintnat caml_max_stack_wsize; CAMLextern uintnat caml_fiber_wsz; CAMLextern uintnat caml_major_cycles_completed; diff --git a/runtime/fiber.c b/runtime/fiber.c index 083d1ef4fb..5a5ed2e995 100644 --- a/runtime/fiber.c +++ b/runtime/fiber.c @@ -496,8 +496,9 @@ int caml_try_realloc_stack(asize_t required_space) old_stack = Caml_state->current_stack; stack_used = Stack_high(old_stack) - (value*)old_stack->sp; wsize = Stack_high(old_stack) - Stack_base(old_stack); + uintnat max_stack_wsize = caml_max_stack_wsize; do { - if (wsize >= caml_max_stack_wsize) return 0; + if (wsize >= max_stack_wsize) return 0; wsize *= 2; } while (wsize < stack_used + required_space); diff --git a/runtime/gc_ctrl.c b/runtime/gc_ctrl.c index 436789591e..6e399af350 100644 --- a/runtime/gc_ctrl.c +++ b/runtime/gc_ctrl.c @@ -38,7 +38,7 @@ #include "caml/startup.h" #include "caml/fail.h" -uintnat caml_max_stack_wsize; +atomic_uintnat caml_max_stack_wsize; uintnat caml_fiber_wsz; extern uintnat caml_percent_free; /* see major_gc.c */ @@ -335,7 +335,7 @@ void caml_init_gc (void) caml_percent_free = norm_pfree (caml_params->init_percent_free); caml_gc_log ("Initial stack limit: %" ARCH_INTNAT_PRINTF_FORMAT "uk bytes", - caml_max_stack_wsize / 1024 * sizeof (value)); + caml_params->init_max_stack_wsz / 1024 * sizeof (value)); caml_custom_major_ratio = norm_custom_maj (caml_params->init_custom_major_ratio);