diff --git a/src/mono/mono/utils/lock-free-alloc.c b/src/mono/mono/utils/lock-free-alloc.c index dfbbd5ed6f7a9..193b3d6aed3f7 100644 --- a/src/mono/mono/utils/lock-free-alloc.c +++ b/src/mono/mono/utils/lock-free-alloc.c @@ -125,7 +125,7 @@ static unsigned long prot_flags_for_activate (int activate) { unsigned long prot_flags = activate? MONO_MMAP_READ|MONO_MMAP_WRITE: MONO_MMAP_NONE; - return prot_flags | MONO_MMAP_PRIVATE | MONO_MMAP_ANON | MONO_MMAP_NOZERO; + return prot_flags | MONO_MMAP_PRIVATE | MONO_MMAP_ANON; } static gpointer @@ -138,13 +138,15 @@ alloc_sb (Descriptor *desc) if (pagesize == -1) pagesize = mono_pagesize (); + // NOTE: Allocated memory is not guaranteed to be zeroed sb_header = desc->block_size == pagesize ? - mono_valloc (NULL, desc->block_size, prot_flags_for_activate (TRUE), desc->heap->account_type) : - mono_valloc_aligned (desc->block_size, desc->block_size, prot_flags_for_activate (TRUE), desc->heap->account_type); + mono_valloc (NULL, desc->block_size, prot_flags_for_activate (TRUE) | MONO_MMAP_NOZERO, desc->heap->account_type) : + mono_valloc_aligned (desc->block_size, desc->block_size, prot_flags_for_activate (TRUE) | MONO_MMAP_NOZERO, desc->heap->account_type); g_assertf (sb_header, "Failed to allocate memory for the lock free allocator"); g_assert (sb_header == sb_header_for_addr (sb_header, desc->block_size)); + // Initializes the header fully *(Descriptor**)sb_header = desc; //g_print ("sb %p for %p\n", sb_header, desc);