Skip to content

Commit c91139f

Browse files
Haris Okanovicgithub-actions
Haris Okanovic
authored and
github-actions
committed
pal init: Move InitializeFlushProcessWriteBuffers() after VIRTUALInitialize()
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
1 parent 7cf8f4a commit c91139f

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -382,16 +382,6 @@ Initialize(
382382
goto CLEANUP0a;
383383
}
384384

385-
if (flags & PAL_INITIALIZE_FLUSH_PROCESS_WRITE_BUFFERS)
386-
{
387-
// Initialize before first thread is created for faster load on Linux
388-
if (!InitializeFlushProcessWriteBuffers())
389-
{
390-
palError = ERROR_PALINIT_INITIALIZE_FLUSH_PROCESS_WRITE_BUFFERS;
391-
goto CLEANUP0a;
392-
}
393-
}
394-
395385
// The gSharedFilesPath is allocated dynamically so its destructor does not get
396386
// called unexpectedly during cleanup
397387
gSharedFilesPath = InternalNew<PathCharString>();
@@ -639,6 +629,17 @@ Initialize(
639629
goto CLEANUP10;
640630
}
641631

632+
if (flags & PAL_INITIALIZE_FLUSH_PROCESS_WRITE_BUFFERS)
633+
{
634+
// Initialize before first thread is created for faster load on Linux
635+
if (!InitializeFlushProcessWriteBuffers())
636+
{
637+
ERROR("Unable to initialize flush process write buffers\n");
638+
palError = ERROR_PALINIT_INITIALIZE_FLUSH_PROCESS_WRITE_BUFFERS;
639+
goto CLEANUP10;
640+
}
641+
}
642+
642643
if (flags & PAL_INITIALIZE_SYNC_THREAD)
643644
{
644645
//

0 commit comments

Comments
 (0)