dotnet/runtime · critical

Error: Fail to PAL_InitializeDLL\n

Error message

Error: Fail to PAL_InitializeDLL\n

What it means

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.

Source

Thrown at src/coreclr/tools/superpmi/superpmi-shim-counter/superpmi-shim-counter.cpp:90

    {
        g_logPath = GetEnvWithDefault("SuperPMIShimLogPath", g_HomeDirectory.c_str());
    }
}

extern "C"
#ifdef HOST_UNIX
    DLLEXPORT // For Win32 PAL LoadLibrary emulation
#endif
        BOOL
        DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
    switch (ul_reason_for_call)
    {
        case DLL_PROCESS_ATTACH:
#ifdef HOST_UNIX
            if (0 != PAL_InitializeDLL())
            {
                fprintf(stderr, "Error: Fail to PAL_InitializeDLL\n");
                exit(1);
            }
#endif // HOST_UNIX
            break;

        case DLL_PROCESS_DETACH:
        case DLL_THREAD_ATTACH:
        case DLL_THREAD_DETACH:
            break;
    }
    return TRUE;
}

extern "C" DLLEXPORT void jitStartup(ICorJitHost* host)
{
    SetDefaultPaths();
    SetLibName();
    SetDebugDumpVariables();

View on GitHub (pinned to 60108ba66e)

Solutions

  1. Use the counter shim produced by the same build as the runtime, with all PAL sibling files present.
  2. Confirm arch/OS match between host runtime and the shim binary.
  3. Loosen the sandbox only for the JIT-loading phase or run the collection on an unrestricted host.
  4. Reproduce under strace to capture the first failing PAL syscall and resolve the missing dependency.
Defensive patterns

Strategy: validation

Validate before calling

#!/usr/bin/env bash
set -euo pipefail
DIR="$(dirname "${DOTNET_JITPATH:-superpmi-shim-counter.so}")"
file "$DIR/superpmi-shim-counter.so" | grep -qi "$(uname -m)" || exit 1
ldd "$DIR/superpmi-shim-counter.so" 2>/dev/null | grep -q 'not found' && exit 1

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of dotnet/runtime@60108ba66e (2026-08-10). Data as JSON: /api/errors/175dd64f8b585d47. Report an issue: GitHub.