From ecabd07453a4233b875939ae8dfcc320df749aa0 Mon Sep 17 00:00:00 2001 From: Mark Shinwell Date: Tue, 2 Jan 2024 12:54:25 +0000 Subject: [PATCH] flambda-backend: Fix caml_alloc_shr_check_gc for tags >= No_scan_tag (#2203) Co-authored-by: Xavier Clerc --- runtime/alloc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/runtime/alloc.c b/runtime/alloc.c index 2cea6c02d0c..6e3186e0e2a 100644 --- a/runtime/alloc.c +++ b/runtime/alloc.c @@ -35,7 +35,7 @@ CAMLexport value caml_alloc (mlsize_t wosize, tag_t tag) value result; mlsize_t i; - CAMLassert (tag < 256); + CAMLassert (tag < Num_tags); CAMLassert (tag != Infix_tag); if (wosize <= Max_young_wosize){ if (wosize == 0){ @@ -67,10 +67,13 @@ CAMLexport value caml_alloc (mlsize_t wosize, tag_t tag) #ifdef NATIVE_CODE CAMLexport value caml_alloc_shr_check_gc (mlsize_t wosize, tag_t tag) { - CAMLassert(tag < No_scan_tag); + CAMLassert (tag < Num_tags); + CAMLassert (tag != Infix_tag); caml_check_urgent_gc (Val_unit); value result = caml_alloc_shr (wosize, tag); - for (mlsize_t i = 0; i < wosize; i++) Field (result, i) = Val_unit; + if (tag < No_scan_tag) { + for (mlsize_t i = 0; i < wosize; i++) Field (result, i) = Val_unit; + } return result; } #endif @@ -405,4 +408,4 @@ CAMLprim value caml_atomic_make_contended(value v) caml_initialize(&Field(res, 0), v); for (mlsize_t i = 1; i < sz; i++) Field(res, i) = Val_unit; CAMLreturn(res); -} \ No newline at end of file +}