{"record":{"id":"acb6c36c2b8a2669","repo":"nodejs/node","slug":"u-memory-allocation-error-acb6c3","errorCode":"U_MEMORY_ALLOCATION_ERROR","errorMessage":"pkgdata: Error: Unable to allocate tmp buffer size: %d\\n","messagePattern":"pkgdata: Error: Unable to allocate tmp buffer size: (.+?)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"deps/icu-small/source/tools/pkgdata/pkgdata.cpp","lineNumber":2136,"sourceCode":"                    if(lineNext) {\n                        *lineNext = 0; /* terminate at space */\n                        lineNext++;\n                    }\n                }\n\n                /* add the file */\n                s = const_cast<char*>(getLongPathname(linePtr));\n\n                /* normal mode.. o->files is just the bare list without package names */\n                o->files = pkg_appendToList(o->files, &tail, uprv_strdup(linePtr));\n                if(uprv_pathIsAbsolute(s) || s[0] == '.') {\n                    fprintf(stderr, \"pkgdata: Error: absolute path encountered. Old style paths are not supported. Use relative paths such as 'fur.res' or 'translit%cfur.res'.\\n\\tBad path: '%s'\\n\", U_FILE_SEP_CHAR, s);\n                    exit(U_ILLEGAL_ARGUMENT_ERROR);\n                }\n                /* The +5 is to add a little extra space for, among other things, PKGDATA_FILE_SEP_STRING */\n                tmpLength = static_cast<int32_t>(uprv_strlen(o->srcDir) + uprv_strlen(s) + 5);\n                if ((tmp = static_cast<char*>(uprv_malloc(tmpLength))) == nullptr) {\n                    fprintf(stderr, \"pkgdata: Error: Unable to allocate tmp buffer size: %d\\n\", tmpLength);\n                    exit(U_MEMORY_ALLOCATION_ERROR);\n                }\n                uprv_strcpy(tmp, o->srcDir);\n                uprv_strcat(tmp, o->srcDir[uprv_strlen(o->srcDir)-1] == U_FILE_SEP_CHAR ? \"\" : PKGDATA_FILE_SEP_STRING);\n                uprv_strcat(tmp, s);\n                o->filePaths = pkg_appendToList(o->filePaths, &tail2, tmp);\n                linePtr = lineNext;\n            } /* for each entry on line */\n        } /* for each line */\n        T_FileStream_close(in);\n    } /* for each file list file */\n}\n\n/* Helper for pkg_getPkgDataPath() */\n#if U_HAVE_POPEN\nstatic UBool getPkgDataPath(const char *cmd, UBool verbose, char *buf, size_t items) {\n    icu::CharString cmdBuf;\n    UErrorCode status = U_ZERO_ERROR;","sourceCodeStart":2118,"sourceCodeEnd":2154,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/icu-small/source/tools/pkgdata/pkgdata.cpp#L2118-L2154","documentation":"uprv_malloc failed to allocate the tmp buffer used to build srcDir + separator + resource path for a file-list entry. pkgdata exits with U_MEMORY_ALLOCATION_ERROR. The buffer size printed is strlen(srcDir)+strlen(s)+5, so this is almost always genuine memory exhaustion or an absurdly large path, not a logic bug.","triggerScenarios":"The build process has exhausted available memory (large parallel make, chroot with low rlimits), or srcDir/s contain a path so long the size overflows int32_t into a negative/huge value passed to a tiny malloc. exit(U_MEMORY_ALLOCATION_ERROR) follows immediately.","commonSituations":"Running a huge ICU data build under cgroups/container memory limits; a corrupted srcDir pointer producing a multi-GB strlen; -jN parallelism set far above RAM.","solutions":["Reduce parallelism (lower make -j) to cut peak memory.","Raise the container/cgroup memory limit for the build.","Inspect srcDir for corruption or an unterminated string.","Run the build on a host with more RAM or add swap."],"exampleFix":"# before: oversubscribed parallelism on limited box\nmake -j32\n\n# after: sane parallelism for available RAM\nmake -j4","handlingStrategy":"fallback","validationCode":"// Nothing in user input reliably prevents OOM, but you can sanity-check srcDir length and memory.\n#include <string.h>\n#include <sys/resource.h>\nbool saneSrcDirAndMemory(const char *srcDir) {\n    if (!srcDir || strlen(srcDir) > 4096) return false;\n    struct rlimit rl;\n    if (getrlimit(RLIMIT_AS, &rl) == 0 && rl.rlim_cur != RLIM_INFINITY && rl.rlim_cur < (256ull*1024*1024))\n        return false; // address space too small for a data build\n    return true;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Lower make -j to reduce peak memory.","Raise container/cgroup memory limits for data builds.","Keep srcDir a normal-length path to avoid size weirdness.","Add swap or build on a host with more RAM."],"tags":["icu","pkgdata","build-tool","memory","u-memory-allocation-error"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}