{"record":{"id":"e8fb62f26b5ccb0e","repo":"NationalSecurityAgency/ghidra","slug":"failed-s-n","errorCode":null,"errorMessage":"Failed: %s\\n","messagePattern":"Failed: (.+?)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"GPL/DemanglerGnu/src/demangler_gnu_v2_41/c/cp-demangle.c","lineNumber":7313,"sourceCode":"\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":7295,"sourceCodeEnd":7323,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/GPL/DemanglerGnu/src/demangler_gnu_v2_41/c/cp-demangle.c#L7295-L7323","documentation":"In the standard standalone demangler build (without IN_GLIBCPP_V3), cplus_demangle_v3() returned NULL for the input token. The tool prints only the original token (no status code) and continues to the next argument. Same condition as error 31, different build configuration.","triggerScenarios":"cplus_demangle_v3(argv[i], options) returns NULL for the current argument. The #else branch (non-GLIBCPP_V3) is compiled. The loop continues processing remaining arguments.","commonSituations":"Feeding non-mangled text or C symbols to c++filt; mangled names from an incompatible ABI; corrupted or truncated mangled strings.","solutions":["Confirm the input is a valid Itanium-ABI mangled name (starts with _Z)","Pre-filter input to skip non-mangled symbols","Use `--no-strip-underscore` if underscore handling is wrong"],"exampleFix":"// before\necho 'main' | c++filt\n// after\necho '_Z3foov' | c++filt","handlingStrategy":"try-catch","validationCode":"// Pre-filter non-mangled strings to avoid the failure path\nstatic int is_mangled_name(const char *s) {\n    if (!s || s[0] != '_') return 0;\n    return s[1] == 'Z'; // Itanium ABI\n}\nfor (int i = optind; i < argc; i++) {\n    if (!is_mangled_name(argv[i])) {\n        printf(\"%s\\n\", argv[i]); // pass through unmangled\n        continue;\n    }\n    char *r = cplus_demangle_v3(argv[i], options);\n    if (r) { printf(\"%s\\n\", r); free(r); }\n    else   printf(\"%s\\n\", argv[i]);\n}","typeGuard":"static int is_demangleable(const char *s) {\n    return s != NULL && s[0] == '_' && s[1] == 'Z';\n}","tryCatchPattern":"char *demangled = cplus_demangle_v3(mangled_str, options);\nif (demangled == NULL) {\n    // Not a valid mangled name — use the original string\n    output(mangled_str);\n} else {\n    output(demangled);\n    free(demangled);\n}","preventionTips":["Check for _Z prefix before attempting demangling","Always handle NULL return from cplus_demangle_v3","Pipe input through a filter that skips non-mangled symbols"],"tags":["demangling","c-plus-plus","standalone","c"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}