Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wasm] Be more cautious about page zeroing #106080

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should some of this be ifdef WASM ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It currently has no effect on other platforms, so it doesn't need to be

}

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
Loading