{"record":{"id":"175dd64f8b585d47","repo":"dotnet/runtime","slug":"error-fail-to-pal-initializedll-n-175dd6","errorCode":null,"errorMessage":"Error: Fail to PAL_InitializeDLL\\n","messagePattern":"Error: Fail to PAL_InitializeDLL\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/coreclr/tools/superpmi/superpmi-shim-counter/superpmi-shim-counter.cpp","lineNumber":90,"sourceCode":"    {\n        g_logPath = GetEnvWithDefault(\"SuperPMIShimLogPath\", g_HomeDirectory.c_str());\n    }\n}\n\nextern \"C\"\n#ifdef HOST_UNIX\n    DLLEXPORT // For Win32 PAL LoadLibrary emulation\n#endif\n        BOOL\n        DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)\n{\n    switch (ul_reason_for_call)\n    {\n        case DLL_PROCESS_ATTACH:\n#ifdef HOST_UNIX\n            if (0 != PAL_InitializeDLL())\n            {\n                fprintf(stderr, \"Error: Fail to PAL_InitializeDLL\\n\");\n                exit(1);\n            }\n#endif // HOST_UNIX\n            break;\n\n        case DLL_PROCESS_DETACH:\n        case DLL_THREAD_ATTACH:\n        case DLL_THREAD_DETACH:\n            break;\n    }\n    return TRUE;\n}\n\nextern \"C\" DLLEXPORT void jitStartup(ICorJitHost* host)\n{\n    SetDefaultPaths();\n    SetLibName();\n    SetDebugDumpVariables();","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/dotnet/runtime/blob/60108ba66eb7d1d12f595480091b4ad80a24b172/src/coreclr/tools/superpmi/superpmi-shim-counter/superpmi-shim-counter.cpp#L72-L108","documentation":"The SuperPMI shim-counter is a drop-in JIT DLL that tallies how often each captured method context is compiled. On unix its DllMain DLL_PROCESS_ATTACH calls PAL_InitializeDLL; on failure it prints this message and exit(1), terminating the host during JIT DLL load. Identical mechanism to the collector shim but for the counter tool.","triggerScenarios":"Setting DOTNET_JitPath / SuperPMIShimPath to the counter shim on unix while PAL_InitializeDLL cannot complete: missing PAL/runtime sibling libraries, arch or CoreCLR-version mismatch, or a sandbox blocking PAL setup syscalls.","commonSituations":"Reusing a counter shim from another branch/build; copying only the .so into the project; running under seccomp/AppArmor that denies mprotect or signal setup; CI image with truncated locale data.","solutions":["Use the counter shim produced by the same build as the runtime, with all PAL sibling files present.","Confirm arch/OS match between host runtime and the shim binary.","Loosen the sandbox only for the JIT-loading phase or run the collection on an unrestricted host.","Reproduce under strace to capture the first failing PAL syscall and resolve the missing dependency."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\nset -euo pipefail\nDIR=\"$(dirname \"${DOTNET_JITPATH:-superpmi-shim-counter.so}\")\"\nfile \"$DIR/superpmi-shim-counter.so\" | grep -qi \"$(uname -m)\" || exit 1\nldd \"$DIR/superpmi-shim-counter.so\" 2>/dev/null | grep -q 'not found' && exit 1","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the counter shim from the matching build artifacts, sibling files included.","Confirm arch/OS match with the host runtime.","Run collection on an unrestricted host if the sandbox blocks PAL setup.","strace the host to find the first failing PAL syscall at DLL_PROCESS_ATTACH."],"tags":["superpmi","shim-counter","pal","dllmain","initialization","unix","jit"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}