{"record":{"id":"a14d2fe09c072b9f","repo":"NationalSecurityAgency/ghidra","slug":"failed-s-status-d","errorCode":null,"errorMessage":"Failed: %s (status %d)","messagePattern":"Failed: (.+?) \\(status (.+?)\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"GPL/DemanglerGnu/src/demangler_gnu_v2_24/c/cp-demangle.c","lineNumber":5977,"sourceCode":"#endif\n\n\t  /* Attempt to demangle.  */\n#ifdef IN_GLIBCPP_V3\n\t  s = __cxa_demangle (argv[i], NULL, NULL, &status);\n#else\n\t  s = cplus_demangle_v3 (argv[i], options);\n#endif\n\n\t  /* If it worked, print the demangled name.  */\n\t  if (s != NULL)\n\t    {\n\t      printf (\"%s\\n\", s);\n\t      free (s);\n\t    }\n\t  else\n\t    {\n#ifdef IN_GLIBCPP_V3\n\t      fprintf (stderr, \"Failed: %s (status %d)\\n\", argv[i], status);\n#else\n\t      fprintf (stderr, \"Failed: %s\\n\", argv[i]);\n#endif\n\t    }\n\t}\n    }\n\n  return 0;\n}\n\n#endif /* STANDALONE_DEMANGLER */\n","sourceCodeStart":5959,"sourceCodeEnd":5989,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/GPL/DemanglerGnu/src/demangler_gnu_v2_24/c/cp-demangle.c#L5959-L5989","documentation":"In the standalone demangler build with IN_GLIBCPP_V3 defined, each command-line argument is passed to __cxa_demangle(argv[i], NULL, NULL, &status). When the result pointer is NULL the demangle failed; the program prints 'Failed: <input> (status <n>)' to stderr and continues to the next argument. The status comes from __cxa_demangle and encodes the failure class (memory/allocation error vs. invalid mangled name). Note this is a diagnostic message, not a thrown error, and the process still returns 0.","triggerScenarios":"Running the standalone c++filt/demangler binary on a string that __cxa_demangle cannot parse (returns NULL). The input was not a valid Itanium C++ ABI mangled name, or was malformed enough to be rejected. status reflects why (e.g. -2 for invalid, -3 for memory).","commonSituations":"Feeding plain C symbols, demangled names, or non-C++ input to the demangler; passing a partially-mangled or truncated mangled name; using the wrong demangling style/ABI for the input (e.g. Itanium demangler on MSVC names); version mismatch between the compiler that mangled and the demangler binary.","solutions":["Confirm the input is actually an Itanium-ABI mangled C++ name (typically starting with _Z) before demangling.","Map the status code to its cause: -1 memory/allocation, -2 invalid mangled name, -3 invalid args; -2 means the input is not valid.","Upgrade/use a demangler version matching the compiler that produced the symbols (ABI/compiler version skew causes false failures).","If running a batch, accept that non-C++ symbols legitimately fail and filter them upstream."],"exampleFix":"# before\n$ c++filt _Z3foov _invalid_token\nFailed: _invalid_token (status -2)\n\n# after - filter to plausible mangled names first\n$ echo _Z3foov | grep -E '^_Z' | c++filt\nfoo()","handlingStrategy":"validation","validationCode":"// Only pass plausible Itanium mangled names to the demangler\n#include <string.h>\nint looksMangled(const char *s) { return s && s[0] == '_' && s[1] == 'Z'; }\nif (looksMangled(argv[i])) {\n    char *r = __cxa_demangle(argv[i], NULL, NULL, &status);\n    ...\n}","typeGuard":"boolean looksLikeItaniumMangled(String s) {\n    return s != null && s.startsWith(\"_Z\");\n}","tryCatchPattern":"// The standalone demangler is a separate process; inspect its exit and stderr.\n// Note: with IN_GLIBCPP_V3 the process still returns 0; detect via stderr text:\nif (stderr_contains(\"Failed:\") && stderr_contains(\"(status -2)\")) {\n    /* input was not a valid mangled name; filter it out and continue */\n}","preventionTips":["Filter inputs to plausible Itanium mangled names (leading _Z) before demangling.","Match the demangler build/version to the compiler that produced the symbols.","Interpret status codes: -1 memory, -2 invalid name, -3 invalid args.","Accept that non-C++ symbols legitimately fail in batch runs."],"tags":["demangler","cli","name-mangling","standalone","diagnostic"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}