dotnet/runtime · critical
Error: Fail to PAL_Initialize\n
Error message
Error: Fail to PAL_Initialize\n
What it means
mcs (the SuperPMI Method-Context Scheduler, a developer tool for replaying captured JIT method contexts) calls PAL_Initialize at startup on Unix to bring up the Platform Adaptation Layer that emulates Win32 APIs. A non-zero return means the PAL could not initialize the process (signals, thread pool, locale, loaded modules). The tool prints this message and exit(1)s immediately, so no method-context work runs.
Source
Thrown at src/coreclr/tools/superpmi/mcs/mcs.cpp:29
#include "verbdumpmap.h"
#include "verbdumptoc.h"
#include "verbjitflags.h"
#include "verbildump.h"
#include "verbtoc.h"
#include "verbremovedup.h"
#include "verbstat.h"
#include "verbconcat.h"
#include "verbmerge.h"
#include "verbstrip.h"
#include "verbprintjiteeversion.h"
#include "logging.h"
int __cdecl main(int argc, char* argv[])
{
#ifdef TARGET_UNIX
if (0 != PAL_Initialize(argc, argv))
{
fprintf(stderr, "Error: Fail to PAL_Initialize\n");
exit(1);
}
#endif // TARGET_UNIX
Logger::Initialize();
CommandLine::Options o;
if (!CommandLine::Parse(argc, argv, &o))
{
return -1;
}
// execute the chosen command.
int exitCode = 0;
if (o.actionASMDump)
{
exitCode = verbASMDump::DoWork(o.nameOfFile1, o.nameOfFile2, o.indexCount, o.indexes);
}View on GitHub (pinned to 60108ba66e)
Solutions
- Run mcs from its build output directory (artifacts/bin/<arch>.<flavor>/...) so the PAL support libraries are found next to it.
- Rebuild SuperPMI for the exact OS/arch you run it on, or use the matching cross-arch runtime.
- Ensure locales are installed (locale -a) and LANG/LC_ALL are valid; fix or unset them if malformed.
- Run under strace -f to capture the first syscall PAL_Initialize fails on (open/mmap of a runtime module is typical).
Defensive patterns
Strategy: validation
Validate before calling
#!/usr/bin/env bash
# Validate mcs can run before invoking it.
set -euo pipefail
BIN="${1:?mcs path required}"
ldd "$BIN" 2>/dev/null | grep -q 'not found' && { echo "missing libs"; exit 1; }
file "$BIN" | grep -qi "$(uname -m)" || { echo "arch mismatch"; exit 1; }
locale -a >/dev/null 2>&1 || echo "warning: locales missing"
"$BIN" -? >/dev/null 2>&1 || true Prevention
- Run SuperPMI tools from their artifacts/bin directory so PAL sibling libraries resolve.
- Never copy a single binary out of its build tree; deploy the whole runtime folder.
- Match arch/OS between the tool build and the execution host.
- Keep locales installed and LANG/LC_ALL valid in CI images.
When it happens
Trigger: Running the mcs binary on a unix host where PAL_Initialize fails: missing or mismatched libcoreclrtrace/libpal runtime files alongside the binary, inability to register signal handlers, /proc or /dev access blocked, locale environment malformed, or running a binary built for a different libc/arch.
Common situations: Copying mcs out of its build/test tree without its sibling runtime files; running an arm64 binary on x86 (or vice versa) without the right runtime; executing inside a minimal container that strips locales or /proc; mixing a SuperPMI build from one .NET branch with runtime support files from another.
Related errors
- Error: Fail to PAL_Initialize\n
- Error: Fail to PAL_InitializeDLL\n
- Error: Fail to PAL_InitializeDLL\n
- Error: Fail to PAL_InitializeDLL\n
- MCH file failed to be generated at: %s
AI-assisted analysis of dotnet/runtime@60108ba66e (2026-08-10).
Data as JSON: /api/errors/46b1623f56310af2.
Report an issue: GitHub.