{"record":{"id":"9629a0f09c3d6bf5","repo":"NationalSecurityAgency/ghidra","slug":"failed-s","errorCode":null,"errorMessage":"Failed: %s","messagePattern":"Failed: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"GPL/DemanglerGnu/src/demangler_gnu_v2_24/c/cp-demangle.c","lineNumber":5979,"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":5961,"sourceCodeEnd":5989,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/GPL/DemanglerGnu/src/demangler_gnu_v2_24/c/cp-demangle.c#L5961-L5989","documentation":"The non-IN_GLIBCPP_V3 standalone-demangler path: each command-line argument is passed to cplus_demangle_v3(argv[i], options); when it returns NULL the program prints 'Failed: <input>' to stderr and moves on. Unlike the GLIBCPP variant it does not report a status code (that API does not surface one), so the message is a pure 'could not demangle' diagnostic. The process still returns 0.","triggerScenarios":"Running the standalone demangler on a token that cplus_demangle_v3 rejects (returns NULL) - i.e. not a valid Itanium C++ mangled name given the selected options/style.","commonSituations":"Passing non-C++ symbols, already-demangled names, or malformed/truncated mangled names; selecting a demangling style (-s) incompatible with the input; using a demangler built for a different ABI than the compiler that produced the symbols.","solutions":["Verify the input is an Itanium-ABI mangled C++ name (leading _Z) before invoking the demangler.","Check the -s style and demangling options match the input's ABI/compiler.","Use a demangler version matching the producing compiler to avoid ABI skew.","Filter non-mangled tokens out of the batch so expected failures do not flood output."],"exampleFix":"# before\n$ demangler _Z3foov plain_name\nFailed: plain_name\n\n# after - only feed mangled names\n$ printf '%s\\n' _Z3foov | demangler\nfoo()","handlingStrategy":"validation","validationCode":"// Pre-filter to Itanium-ABI mangled names before invoking the standalone demangler\n#include <string.h>\nint looksMangled(const char *s) { return s && s[0] == '_' && s[1] == 'Z'; }\nif (looksMangled(tok)) demangle_it(tok);\nelse fputs(tok, stdout); /* pass through unchanged */","typeGuard":"boolean looksLikeItaniumMangled(String s) {\n    return s != null && s.startsWith(\"_Z\");\n}","tryCatchPattern":"// Standalone tool still returns 0; detect via stderr text.\nif (rc == 0 && stderr_contains(\"Failed:\")) {\n    /* one or more tokens were not valid mangled names; expected for mixed input */\n}","preventionTips":["Filter to plausible mangled names (leading _Z) before demangling.","Use a demangler version matching the producing compiler.","Confirm the -s style matches the input's ABI.","In batch runs, treat non-C++ tokens as expected failures."],"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"}