{"record":{"id":"46b1623f56310af2","repo":"dotnet/runtime","slug":"error-fail-to-pal-initialize-n","errorCode":null,"errorMessage":"Error: Fail to PAL_Initialize\\n","messagePattern":"Error: Fail to PAL_Initialize\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/coreclr/tools/superpmi/mcs/mcs.cpp","lineNumber":29,"sourceCode":"#include \"verbdumpmap.h\"\n#include \"verbdumptoc.h\"\n#include \"verbjitflags.h\"\n#include \"verbildump.h\"\n#include \"verbtoc.h\"\n#include \"verbremovedup.h\"\n#include \"verbstat.h\"\n#include \"verbconcat.h\"\n#include \"verbmerge.h\"\n#include \"verbstrip.h\"\n#include \"verbprintjiteeversion.h\"\n#include \"logging.h\"\n\nint __cdecl main(int argc, char* argv[])\n{\n#ifdef TARGET_UNIX\n    if (0 != PAL_Initialize(argc, argv))\n    {\n        fprintf(stderr, \"Error: Fail to PAL_Initialize\\n\");\n        exit(1);\n    }\n#endif // TARGET_UNIX\n\n    Logger::Initialize();\n\n    CommandLine::Options o;\n    if (!CommandLine::Parse(argc, argv, &o))\n    {\n        return -1;\n    }\n\n    // execute the chosen command.\n    int exitCode = 0;\n    if (o.actionASMDump)\n    {\n        exitCode = verbASMDump::DoWork(o.nameOfFile1, o.nameOfFile2, o.indexCount, o.indexes);\n    }","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/dotnet/runtime/blob/60108ba66eb7d1d12f595480091b4ad80a24b172/src/coreclr/tools/superpmi/mcs/mcs.cpp#L11-L47","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\n# Validate mcs can run before invoking it.\nset -euo pipefail\nBIN=\"${1:?mcs path required}\"\nldd \"$BIN\" 2>/dev/null | grep -q 'not found' && { echo \"missing libs\"; exit 1; }\nfile \"$BIN\" | grep -qi \"$(uname -m)\" || { echo \"arch mismatch\"; exit 1; }\nlocale -a >/dev/null 2>&1 || echo \"warning: locales missing\"\n\"$BIN\" -? >/dev/null 2>&1 || true","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["superpmi","mcs","pal","initialization","unix","developer-tool"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}