Skip to content

Commit

Permalink
pal init: Move InitializeFlushProcessWriteBuffers() after VIRTUALInit…
Browse files Browse the repository at this point in the history
…ialize()

A fixup of commit 27ee590 that's broken on platforms which don't
support membarrier() syscall: GetVirtualPageSize() is called in the
fallback path of InitializeFlushProcessWriteBuffers() and attempts to
mmap() zero bytes.

Move InitializeFlushProcessWriteBuffers() after VIRTUALInitialize() but
before the first thread is created.

Fixes #106892
Fixes #106722
  • Loading branch information
Haris Okanovic authored and github-actions committed Aug 28, 2024
1 parent 7cf8f4a commit c91139f
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/coreclr/pal/src/init/pal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,16 +382,6 @@ Initialize(
goto CLEANUP0a;
}

if (flags & PAL_INITIALIZE_FLUSH_PROCESS_WRITE_BUFFERS)
{
// Initialize before first thread is created for faster load on Linux
if (!InitializeFlushProcessWriteBuffers())
{
palError = ERROR_PALINIT_INITIALIZE_FLUSH_PROCESS_WRITE_BUFFERS;
goto CLEANUP0a;
}
}

// The gSharedFilesPath is allocated dynamically so its destructor does not get
// called unexpectedly during cleanup
gSharedFilesPath = InternalNew<PathCharString>();
Expand Down Expand Up @@ -639,6 +629,17 @@ Initialize(
goto CLEANUP10;
}

if (flags & PAL_INITIALIZE_FLUSH_PROCESS_WRITE_BUFFERS)
{
// Initialize before first thread is created for faster load on Linux
if (!InitializeFlushProcessWriteBuffers())
{
ERROR("Unable to initialize flush process write buffers\n");
palError = ERROR_PALINIT_INITIALIZE_FLUSH_PROCESS_WRITE_BUFFERS;
goto CLEANUP10;
}
}

if (flags & PAL_INITIALIZE_SYNC_THREAD)
{
//
Expand Down

0 comments on commit c91139f

Please sign in to comment.