From 0a868484db29857575740aadeb278489c8ecfb13 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Tue, 9 Feb 2021 14:38:54 +0000 Subject: [PATCH] Mac M1 fix (#278) The actual code works fine on the usual mac Intel however, some failures occurs with some unit tests on the ARM h/w when zero'ing page ranges. --- src/pal/pal_apple.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/pal/pal_apple.h b/src/pal/pal_apple.h index 22600f8..53336d3 100644 --- a/src/pal/pal_apple.h +++ b/src/pal/pal_apple.h @@ -35,6 +35,21 @@ namespace snmalloc * descriptor for the mapping. */ static constexpr int anonymous_memory_fd = VM_MAKE_TAG(PALAnonID); + + /** + * Note: The root's implementation works fine on Intel + * however mprotect/PROT_NONE fails on ARM + * especially since the 11.2 release (seems known issue + * spotted in various projects; might be a temporary fix). + */ + template + static void zero(void* p, size_t size) noexcept + { + if constexpr (Aal::aal_name != ARM) + PALBSD::zero(p, size); + else + ::bzero(p, size); + } }; } // namespace snmalloc #endif