dotnet/runtime · critical

Out of memory!

Error message

Out of memory!

What it means

Printed in BinStrToUnicode() (asmman.cpp) when tmp = new BinStr() succeeded but tmp->getBuff(L) returned NULL — i.e. the BinStr could not allocate a buffer of L = sizeof(WCHAR)*inputLength bytes for the Unicode conversion. The function then deletes tmp, returns NULL. ilasm continues but the conversion is dropped.

Source

Thrown at src/coreclr/ilasm/asmman.cpp:43

        if(tmp)
        {
            WCHAR*  wz = (WCHAR*)(tmp->getBuff(L));
            if(wz)
            {
                memset(wz,0,L);
                MultiByteToWideChar(g_uCodePage,0,pb,-1,wz,l);
                tmp->remove(L-(DWORD)u16_strlen(wz)*sizeof(WCHAR));
#if BIGENDIAN
                if (Swap)
                    SwapStringLength(wz, (DWORD)u16_strlen(wz));
#endif
                delete pSource;
            }
            else
            {
                delete tmp;
                tmp = NULL;
                fprintf(stderr,"\nOut of memory!\n");
            }
        }
        else
            fprintf(stderr,"\nOut of memory!\n");
        return tmp;
    }
    return NULL;
}

AsmManFile*         AsmMan::GetFileByName(_In_ __nullterminated char* szFileName)
{
    AsmManFile* ret = NULL;
    if(szFileName)
    {
        //AsmManFile X;
        //X.szName = szFileName;
        //ret = m_FileLst.FIND(&X);
        //X.szName = NULL;

View on GitHub (pinned to 290d5ab72c)

Solutions

  1. Reduce the size of the input .il — split large embedded blobs or externalize resources.
  2. Run on a 64-bit ilasm build with more address space.
  3. Increase memory limits (cgroup/ulimit) for the process.
  4. If reproducible, profile which BinStr is oversized and report an ilasm bug — getBuff should not silently fail.
Defensive patterns

Strategy: validation

Validate before calling

# before assembling, sanity-check input size vs available memory
ILSIZE=$(stat -c%s huge.il 2>/dev/null || stat -f%z huge.il)
AVAIL=$(awk '/MemAvailable/{print int($2*1024)}' /proc/meminfo)
[ "$((ILSIZE*4))" -lt "$AVAIL" ] || echo "warning: il size ~$((ILSIZE/1024/1024))MB, avail ~$((AVAIL/1024/1024))MB - OOM likely"

Prevention

When it happens

Trigger: Assembling an IL source whose string/metadata tokens are so large that the WCHAR buffer (2 bytes per source byte) exceeds available memory. BinStrToUnicode is used for manifest/assembly-name string conversion during IL assembly.

Common situations: Very large generated .il files; embedded large binary blobs as strings; running ilasm in a memory-constrained container; 32-bit ilasm hitting address-space limits.

Related errors


AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06). Data as JSON: /api/errors/51b32158aaba0761. Report an issue: GitHub.