nodejs/node · error

U_ILLEGAL_ARGUMENT_ERROR

U_ILLEGAL_ARGUMENT_ERROR

Error message

genccode: filename too long

What it means

Thrown by genccode's writeAssemblyCode when the computed output filename length is greater than or equal to the caller-provided outFilePathCapacity. This is a buffer-safety guard: the resolved path would not fit in the caller's outFilePath buffer, so it aborts before copying.

Source

Thrown at deps/icu-small/source/tools/toolutil/pkg_genc.cpp:369

    getOutFilename(
        filename,
        destdir,
        buffer.chars,
        sizeof(buffer.chars),
        entry,
        sizeof(entry),
        newSuffix,
        optFilename);
    out=T_FileStream_open(buffer.chars, "w");
    if(out==nullptr) {
        fprintf(stderr, "genccode: unable to open output file %s\n", buffer.chars);
        exit(U_FILE_ACCESS_ERROR);
    }

    if (outFilePath != nullptr) {
        if (uprv_strlen(buffer.chars) >= outFilePathCapacity) {
            fprintf(stderr, "genccode: filename too long\n");
            exit(U_ILLEGAL_ARGUMENT_ERROR);
        }
        uprv_strcpy(outFilePath, buffer.chars);
#if defined (WINDOWS_WITH_GNUC) && U_PLATFORM != U_PF_CYGWIN
        /* Need to fix the file separator character when using MinGW. */
        swapFileSepChar(outFilePath, U_FILE_SEP_CHAR, '/');
#endif
    }

    if(optEntryPoint != nullptr) {
        uprv_strcpy(entry, optEntryPoint);
        uprv_strcat(entry, "_dat");
    }

    /* turn dashes or dots in the entry name into underscores */
    length=uprv_strlen(entry);
    for(i=0; i<length; ++i) {
        if(entry[i]=='-' || entry[i]=='.') {

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Shorten the destination directory path (-d) to reduce total length.
  2. Increase the outFilePath buffer size in the calling code (the build system / Makefile).
  3. Move the build root closer to the filesystem root to trim path depth.
  4. Use relative paths where the build system allows.

Example fix

// before (caller)
char outFilePath[64];
writeAssemblyCode(..., outFilePath, sizeof(outFilePath)); // too short

// after
char outFilePath[PATH_MAX];
writeAssemblyCode(..., outFilePath, sizeof(outFilePath));
Defensive patterns

Strategy: validation

Validate before calling

// Before calling writeAssemblyCode, ensure your outFilePath buffer is large
// enough for any plausible output path.
#include <climits>   // PATH_MAX
#include <cstring>
bool pathBufferAdequate(size_t cap, const char* destdir, const char* name) {
    size_t need = std::strlen(destdir) + std::strlen(name) + 8; // sep + suffix + slop
    return cap > need && cap >= PATH_MAX;
}

Prevention

When it happens

Trigger: When outFilePath != nullptr, the code checks uprv_strlen(buffer.chars) >= outFilePathCapacity before uprv_strcpy. Failure means the path (destdir + name + suffix) is too long for the receiving buffer.

Common situations: Very deep build directory trees; very long ICU data filenames; deeply nested absolute paths on Windows; a caller passing a too-small buffer; symlink-heavy paths that expand.

Related errors


AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13). Data as JSON: /api/errors/2f080364f5902524. Report an issue: GitHub.