Skip to content

Commit c655529

Browse files
harisokanovicHaris Okanovic
and
Haris Okanovic
authored
pal init: Move InitializeFlushProcessWriteBuffers() after VIRTUALInitialize() (#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 #106892 Fixes #106722 Co-authored-by: Haris Okanovic <[email protected]>
1 parent 6f80da6 commit c655529

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/coreclr/pal/src/init/pal.cpp

+11-10
Original file line numberDiff line numberDiff line change
@@ -359,16 +359,6 @@ Initialize(
359359
goto CLEANUP0a;
360360
}
361361

362-
if (flags & PAL_INITIALIZE_FLUSH_PROCESS_WRITE_BUFFERS)
363-
{
364-
// Initialize before first thread is created for faster load on Linux
365-
if (!InitializeFlushProcessWriteBuffers())
366-
{
367-
palError = ERROR_PALINIT_INITIALIZE_FLUSH_PROCESS_WRITE_BUFFERS;
368-
goto CLEANUP0a;
369-
}
370-
}
371-
372362
// The gSharedFilesPath is allocated dynamically so its destructor does not get
373363
// called unexpectedly during cleanup
374364
gSharedFilesPath = InternalNew<PathCharString>();
@@ -616,6 +606,17 @@ Initialize(
616606
goto CLEANUP10;
617607
}
618608

609+
if (flags & PAL_INITIALIZE_FLUSH_PROCESS_WRITE_BUFFERS)
610+
{
611+
// Initialize before first thread is created for faster load on Linux
612+
if (!InitializeFlushProcessWriteBuffers())
613+
{
614+
ERROR("Unable to initialize flush process write buffers\n");
615+
palError = ERROR_PALINIT_INITIALIZE_FLUSH_PROCESS_WRITE_BUFFERS;
616+
goto CLEANUP10;
617+
}
618+
}
619+
619620
if (flags & PAL_INITIALIZE_SYNC_THREAD)
620621
{
621622
//

0 commit comments

Comments
 (0)