Skip to content

Commit

Permalink
[wasm] Be more cautious about page zeroing (#106080)
Browse files Browse the repository at this point in the history
Should fix #106007
  • Loading branch information
kg committed Aug 8, 2024
1 parent 679a284 commit 68511fd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/mono/mono/utils/lock-free-alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);

Expand Down

0 comments on commit 68511fd

Please sign in to comment.