{"record":{"id":"ffdd85a13bd2d8e6","repo":"dotnet/runtime","slug":"error-fail-to-pal-initialize","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/ilasm/main.cpp","lineNumber":886,"sourceCode":"            printf(\"               Fixup and linking         %d\\n\",(int)(cw.cFilegenBegin - cw.cMDEmitEnd));\n            printf(\"               CEE file generation       %d\\n\",(int)(cw.cFilegenEnd - cw.cFilegenBegin));\n            printf(\"               PE file writing           %d\\n\",(int)(cw.cEnd - cw.cFilegenEnd));\n        }\n    }\n    else\n    {\n        printf(\"\\n***** FAILURE ***** \\n\");\n    }\n    exit(exitval);\n    return exitval;\n}\n\n#ifdef TARGET_UNIX\nint main(int argc, char* str[])\n{\n    if (0 != PAL_Initialize(argc, str))\n    {\n        fprintf(stderr,\"Error: Fail to PAL_Initialize\\n\");\n        exit(1);\n    }\n\n    WCHAR **argv = new WCHAR*[argc];\n    for (int i = 0; i < argc; i++) {\n        int length = MultiByteToWideChar(CP_ACP, 0, str[i], -1, NULL, 0);\n        ASSERTE_ALL_BUILDS(length != 0);\n\n        LPWSTR result = new (nothrow) WCHAR[length];\n        ASSERTE_ALL_BUILDS(result != NULL);\n\n        length = MultiByteToWideChar(CP_ACP, 0, str[i], -1, result, length);\n        ASSERTE_ALL_BUILDS (length != 0);\n\n        argv[i] = result;\n    }\n\n    int ret = wmain(argc, argv);","sourceCodeStart":868,"sourceCodeEnd":904,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/coreclr/ilasm/main.cpp#L868-L904","documentation":"On Unix (TARGET_UNIX) the ilasm `main` calls PAL_Initialize to bootstrap the Platform Abstraction Layer before doing anything (main.cpp:884). A nonzero return means the PAL could not initialize the runtime environment (threading, locale, file system, etc.); ilasm prints this and `exit(1)` immediately. No assembly work happens.","triggerScenarios":"Running an ilasm binary whose PAL runtime files are missing or wrong version; a corrupted install; a host OS/glibc incompatible with the bundled PAL.","commonSituations":"Copying an ilasm binary without its runtime directory; running on an unsupported distro/glibc; LD_LIBRARY_PATH shadowing the PAL libraries.","solutions":["Reinstall the .NET/CoreCLR SDK so the PAL libraries match the ilasm binary.","Clear or correct LD_LIBRARY_PATH so the bundled PAL libs are found.","Run on a supported OS/glibc version for that ilasm build."],"exampleFix":"# before: mismatched runtime\nLD_LIBRARY_PATH=/opt/oldlibs ilasm foo.il   # Error: Fail to PAL_Initialize\n# after\nunset LD_LIBRARY_PATH && /usr/share/dotnet/ilasm foo.il","handlingStrategy":"fallback","validationCode":"# Verify the PAL libraries resolve before running ilasm.\nif ! ldd \"$(command -v ilasm)\" | grep -qi 'libclr.*pal\\|libcoreclrpal'; then\n  echo 'PAL libraries unresolved; install will fail to PAL_Initialize'; exit 1\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install ilasm from the matching .NET SDK package; do not copy the binary alone.","Avoid shadowing the PAL with LD_LIBRARY_PATH.","Run on a supported distro/glibc for the ilasm build."],"tags":["ilasm","pal","unix","initialization","install"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}