NationalSecurityAgency/ghidra · error
%s: error: too many @-files encountered
Error message
%s: error: too many @-files encountered
What it means
In libiberty's buildargv/expandargv-style argument processing (argv.c), command-line tokens of the form @file are expanded by reading the named response file and inserting its contents as arguments. A counter (iteration_limit, initialized to 2000) bounds how many @-files are processed to stop infinite recursion (e.g. @a includes @a, or a cycle). When the counter hits zero the program prints this error and calls xexit(1).
Source
Thrown at GPL/DemanglerGnu/src/demangler_gnu_v2_24/c/argv.c:406
/* The number of characters in the response file, when actually
read. */
size_t len;
/* A dynamically allocated buffer used to hold options read from a
response file. */
char *buffer;
/* Dynamically allocated storage for the options read from the
response file. */
char **file_argv;
/* The number of options read from the response file, if any. */
size_t file_argc;
/* We are only interested in options of the form "@file". */
filename = (*argvp)[i];
if (filename[0] != '@')
continue;
/* If we have iterated too many times then stop. */
if (-- iteration_limit == 0)
{
fprintf (stderr, "%s: error: too many @-files encountered\n", (*argvp)[0]);
xexit (1);
}
/* Read the contents of the file. */
f = fopen (++filename, "r");
if (!f)
continue;
if (fseek (f, 0L, SEEK_END) == -1)
goto error;
pos = ftell (f);
if (pos == -1)
goto error;
if (fseek (f, 0L, SEEK_SET) == -1)
goto error;
buffer = (char *) xmalloc (pos * sizeof (char) + 1);
len = fread (buffer, sizeof (char), pos, f);
if (len != (size_t) pos
/* On Windows, fread may return a value smaller than POS,
due to CR/LF->CR translation when reading text files.View on GitHub (pinned to d5f144c24d)
Solutions
- Check response files for self-references or mutual cycles (grep for the file's own name inside it).
- Regenerate the response file so it lists only real arguments, never @-references back into itself.
- Remove the @file indirection and pass arguments directly to confirm the cycle is the cause.
- Audit build scripts/templates that produce @-files to exclude the response file path from its own contents.
Example fix
# before: build/link.args contains a line '@link.args' (self-reference) clang @build/link.args main.c # after: regenerate build/link.args without self-inclusion # (e.g. exclude the args file itself from the glob that writes it) clang @build/link.args main.c
Defensive patterns
Strategy: validation
Validate before calling
// Validate response files for self-reference before invoking the tool
#include <stdio.h>
#include <string.h>
int self_references(const char *file) {
/* returns 1 if 'file' contains an @-ref to itself */
FILE *f = fopen(file, "r"); char line[4096]; int found = 0;
if (!f) return 0;
while (fgets(line, sizeof line, f))
if (strstr(line, file)) { found = 1; break; }
fclose(f); return found;
} Type guard
// detect a cycle in @-file references before passing to the tool bool hasResponseFileCycle(const std::vector<std::string>& files);
Try / catch
// This is a CLI invocation error that calls xexit(1); it cannot be caught.
// Capture child stderr and non-zero exit code in the calling process:
int rc = run_child({"clang", "@build/args", "main.c"});
if (rc != 0 && stderr_contains("too many @-files")) {
report("response file cycle detected; regenerating @build/args without self-reference");
} Prevention
- When generating @-files, exclude the response file's own path from its contents.
- Lint response files for self-references and mutual cycles before builds.
- Prefer passing arguments directly when the argument count is small.
- Audit build scripts/templates that glob arguments into a file that the glob also matches.
When it happens
Trigger: Supplying a @file argument whose response file(s) transitively reference enough @-files to exhaust the 2000-deep limit, typically via a circular chain (file @a contains '@a') or a very deep, self-referential include graph.
Common situations: A generated response file accidentally includes itself (common with build tools that emit @file from a glob that contains the response file); a circular reference between two response files; an extremely large, deliberately nested set of @-files. This is a build/CLI invocation problem, not a runtime data problem.
Related errors
- Failed: %s (status %d)
- Failed: %s
- %s: unknown demangling style `%s'
- %s: option `%s' is ambiguous
- %s: option `--%s' doesn't allow an argument
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/17453d31fe858f73.
Report an issue: GitHub.