{"record":{"id":"bc846958589c1b05","repo":"dotnet/runtime","slug":"error-fail-to-pal-initializedll-n","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-collector/superpmi-shim-collector.cpp","lineNumber":108,"sourceCode":"    if (g_collectionFilter != nullptr)\n    {\n        fprintf(stderr, \"*** SPMI filter '%s'\\n\", g_collectionFilter);\n    }\n}\n\nvoid InitializeShim()\n{\n    if (g_initialized)\n    {\n        return;\n    }\n\n#ifdef HOST_UNIX\n    // Register signal handlers for the shim so we can handle committing collections on JIT segfaults.\n    PAL_SetInitializeDLLFlags(PAL_INITIALIZE_REGISTER_SIGNALS);\n    if (0 != PAL_InitializeDLL())\n    {\n        fprintf(stderr, \"Error: Fail to PAL_InitializeDLL\\n\");\n        exit(1);\n    }\n#endif // HOST_UNIX\n\n#ifdef HOST_WINDOWS\n    // Assertions will be sent to stderr instead of a pop-up dialog.\n    _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);\n    _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);\n#endif // HOST_WINDOWS\n\n    g_initialized = true;\n}\n\nextern \"C\"\n#ifdef HOST_UNIX\n    DLLEXPORT // For Win32 PAL LoadLibrary emulation\n#endif\n        BOOL","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/dotnet/runtime/blob/60108ba66eb7d1d12f595480091b4ad80a24b172/src/coreclr/tools/superpmi/superpmi-shim-collector/superpmi-shim-collector.cpp#L90-L126","documentation":"The SuperPMI shim-collector is a replacement JIT DLL loaded by CoreCLR to record method contexts during compilation. On unix its InitializeShim (called from DllMain DLL_PROCESS_ATTACH) sets PAL_INITIALIZE_REGISTER_SIGNALS and calls PAL_InitializeDLL to set up the in-process PAL. If that returns non-zero the shim cannot function and calls exit(1), killing the host process at JIT-startup time.","triggerScenarios":"Loading superpmi-shim-collector via DOTNET_JitPath / SuperPMIShimPath on unix when the PAL cannot initialize: missing runtime PAL modules next to the shim, mismatched CoreCLR build vs shim build, signal-handler registration blocked, or running under a sandbox that blocks the syscalls PAL needs.","commonSituations":"Pointing DOTNET_JitPath at a shim built for a different .NET version/arch; deploying only the shim DLL without its libpal/runtime siblings; enabling the collector in a restricted container; stale build artifacts after switching git branches.","solutions":["Build and use the shim-collector from the same CoreCLR artifacts tree as the runtime that hosts it.","Deploy all sibling runtime/PAL files alongside superpmi-shim-collector.so in the directory named by SuperPMIShimPath.","Verify the target arch matches (file superpmi-shim-collector.so) and that the host runtime is the same arch.","Run with DOTNET_DiagnosticPorts= or under strace to see which PAL dependency/fails during DLL_PROCESS_ATTACH."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\n# Validate the shim-collector is co-located with its PAL runtime siblings.\nset -euo pipefail\nDIR=\"$(dirname \"${DOTNET_JITPATH:-superpmi-shim-collector.so}\")\"\nfile \"$DIR/superpmi-shim-collector.so\" | grep -qi \"$(uname -m)\" || { echo arch; exit 1; }\nldd \"$DIR/superpmi-shim-collector.so\" 2>/dev/null | grep -q 'not found' && { echo missing; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build and deploy the shim from the same CoreCLR artifacts tree as the host runtime.","Always keep PAL/runtime sibling files next to the shim .so.","Verify arch/OS match before enabling the collector.","strace the host at JIT load time to catch the first failing PAL syscall early."],"tags":["superpmi","shim-collector","pal","dllmain","initialization","unix","jit"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}