NationalSecurityAgency/ghidra · warning
Failed: %s (status %d)\n
Error message
Failed: %s (status %d)\n
What it means
In the standalone demangler built with IN_GLIBCPP_V3 defined, cplus_demangle_v3() returned NULL for the given input token, indicating the string could not be demangled. The tool prints the original token and the internal status code, then continues to the next argument. This is a per-token warning, not a fatal error.
Source
Thrown at GPL/DemanglerGnu/src/demangler_gnu_v2_41/c/cp-demangle.c:7311
#endif
/* Attempt to demangle. */
#ifdef IN_GLIBCPP_V3
s = __cxa_demangle (argv[i], NULL, NULL, &status);
#else
s = cplus_demangle_v3 (argv[i], options);
#endif
/* If it worked, print the demangled name. */
if (s != NULL)
{
printf ("%s\n", s);
free (s);
}
else
{
#ifdef IN_GLIBCPP_V3
fprintf (stderr, "Failed: %s (status %d)\n", argv[i], status);
#else
fprintf (stderr, "Failed: %s\n", argv[i]);
#endif
}
}
}
return 0;
}
#endif /* STANDALONE_DEMANGLER */
View on GitHub (pinned to d5f144c24d)
Solutions
- Verify the input is actually a mangled C++ name (starts with _Z for Itanium ABI)
- Filter non-mangled symbols before passing to the demangler
- If status indicates allocation failure, check available memory
Example fix
// before echo 'plain_text' | c++filt // after echo '_ZN3foo3barEv' | c++filt
Defensive patterns
Strategy: try-catch
Validate before calling
// Check if a string looks like a mangled name before demangling
static int looks_mangled(const char *s) {
if (!s || !s[0]) return 0;
// Itanium ABI mangled names start with _Z
if (s[0] == '_' && s[1] == 'Z') return 1;
return 0;
}
// Filter before calling cplus_demangle_v3
for (int i = optind; i < argc; i++) {
if (!looks_mangled(argv[i])) continue;
char *r = cplus_demangle_v3(argv[i], options);
if (r) { printf("%s\n", r); free(r); }
} Type guard
static int is_itanium_mangled(const char *s) {
return s && s[0] == '_' && s[1] == 'Z';
} Try / catch
char *result = cplus_demangle_v3(input, options);
if (result == NULL) {
// Demangling failed — input may not be a mangled name
// Log or skip; do not treat as fatal
fprintf(stderr, "Demangling failed for: %s\n", input);
} else {
printf("%s\n", result);
free(result);
} Prevention
- Filter input to only Itanium-ABI mangled names (prefix _Z)
- Always check the return value of cplus_demangle_v3 for NULL
- Handle non-mangled symbols gracefully by passing them through unchanged
When it happens
Trigger: cplus_demangle_v3(argv[i], options) returns NULL and sets status to a non-zero value (e.g. memory allocation failure or malformed mangled name). The IN_GLIBCPP_V3 preprocessor branch is active.
Common situations: Passing a non-mangled string to the demangler (e.g. plain text, a C symbol); passing a mangled name from an unsupported mangling scheme; memory exhaustion during demangling.
Related errors
- Failed: %s\n
- %s: unknown demangling style `%s'\n
- Internal error: no symbol alphabet for current style\n
- Failed: %s (status %d)
- Failed: %s
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/411787ba9c740a12.
Report an issue: GitHub.