Skip to content

Commit

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

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

Co-authored-by: Haris Okanovic <harisokn@amazon.com>
  • Loading branch information
github-actions[bot] and Haris Okanovic authored Aug 29, 2024
1 parent 0550bcd commit 0a5cccb
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 0a5cccb

Please sign in to comment.