Skip to content

Commit

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

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 dotnet#106892
Fixes dotnet#106722

Co-authored-by: Haris Okanovic <[email protected]>
  • Loading branch information
2 people authored and jtschuster committed Sep 17, 2024
1 parent dcc032b commit f2c3044
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 @@ -359,16 +359,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 @@ -616,6 +606,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 f2c3044

Please sign in to comment.