NationalSecurityAgency/ghidra · critical

Internal error: no symbol alphabet for current style\n

Error message

Internal error: no symbol alphabet for current style\n

What it means

In cxxfilt's symbol-character selection switch, the default case fires when the current demangling style has no explicit case for setting valid_symbols. The original code called fatal(); it was changed to fprintf + exit(1) on 10/31/23. Explicit cases exist for gnu_v3, java, gnat, dlang, and rust demangling.

Source

Thrown at GPL/DemanglerGnu/src/demangler_gnu_v2_41/c/cxxfilt.c:252

      return 0;
    }

  switch (current_demangling_style)
    {
    case auto_demangling:
    case gnu_v3_demangling:
    case java_demangling:
    case gnat_demangling:
    case dlang_demangling:
    case rust_demangling:
       valid_symbols = standard_symbol_characters ();
      break;
    default:
      /* Folks should explicitly indicate the appropriate alphabet for
	 each demangling.  Providing a default would allow the
	 question to go unconsidered.  */
      // fatal ("Internal error: no symbol alphabet for current style"); // Changed 10/31/23
      fprintf (stderr, "Internal error: no symbol alphabet for current style\n"); // Changed 10/31/23	
  		exit (1);                                       						  // Changed 10/31/23
      
    }

  for (;;)
    {
      static char mbuffer[32767];
      unsigned i = 0;

      c = getchar ();
      /* Try to read a mangled name.  */
      while (c != EOF && (ISALNUM (c) || strchr (valid_symbols, c)))
	{
	  if (i >= sizeof (mbuffer) - 1)
	    break;
	  mbuffer[i++] = c;
	  c = getchar ();
	}

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Ensure the demangling style is set to a known value before reading input
  2. Add a case for the missing style with appropriate symbol characters
  3. Set a default style like gnu_v3 at startup

Example fix

// before
style = unknown_demangling; // no case in switch
// after
style = gnu_v3_demangling; // has explicit case
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the demangling style is set to a known value before reading input
static int is_supported_style(enum demangling_styles style) {
    switch (style) {
        case gnu_v3_demangling:
        case java_demangling:
        case gnat_demangling:
        case dlang_demangling:
        case rust_demangling:
            return 1;
        default:
            return 0;
    }
}
// Before entering the symbol-reading loop:
if (!is_supported_style(current_style)) {
    current_style = gnu_v3_demangling; // safe default
    cplus_demangle_set_style(current_style);
}

Type guard

static int has_symbol_alphabet(enum demangling_styles s) {
    switch (s) {
        case gnu_v3_demangling: case java_demangling:
        case gnat_demangling: case dlang_demangling:
        case rust_demangling:
            return 1;
        default:
            return 0;
    }
}

Prevention

When it happens

Trigger: The current_style enum value is none of gnu_v3_demangling, java_demangling, gnat_demangling, dlang_demangling, or rust_demangling. This indicates a programming error or an uninitialized/unknown style being set before the switch.

Common situations: Calling the demangler library with an uninitialized or unknown_demangling style; a code path that sets the style to a value without a corresponding case; regression from modifying the style initialization.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/134e5aee569d144f. Report an issue: GitHub.