{"record":{"id":"411787ba9c740a12","repo":"NationalSecurityAgency/ghidra","slug":"failed-s-status-d-n","errorCode":null,"errorMessage":"Failed: %s (status %d)\\n","messagePattern":"Failed: (.+?) \\(status (.+?)\\)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"GPL/DemanglerGnu/src/demangler_gnu_v2_41/c/cp-demangle.c","lineNumber":7311,"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":7293,"sourceCodeEnd":7323,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/GPL/DemanglerGnu/src/demangler_gnu_v2_41/c/cp-demangle.c#L7293-L7323","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\necho 'plain_text' | c++filt\n// after\necho '_ZN3foo3barEv' | c++filt","handlingStrategy":"try-catch","validationCode":"// Check if a string looks like a mangled name before demangling\nstatic int looks_mangled(const char *s) {\n    if (!s || !s[0]) return 0;\n    // Itanium ABI mangled names start with _Z\n    if (s[0] == '_' && s[1] == 'Z') return 1;\n    return 0;\n}\n// Filter before calling cplus_demangle_v3\nfor (int i = optind; i < argc; i++) {\n    if (!looks_mangled(argv[i])) continue;\n    char *r = cplus_demangle_v3(argv[i], options);\n    if (r) { printf(\"%s\\n\", r); free(r); }\n}","typeGuard":"static int is_itanium_mangled(const char *s) {\n    return s && s[0] == '_' && s[1] == 'Z';\n}","tryCatchPattern":"char *result = cplus_demangle_v3(input, options);\nif (result == NULL) {\n    // Demangling failed — input may not be a mangled name\n    // Log or skip; do not treat as fatal\n    fprintf(stderr, \"Demangling failed for: %s\\n\", input);\n} else {\n    printf(\"%s\\n\", result);\n    free(result);\n}","preventionTips":["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"],"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"}