Skip to content

6.4.3

Latest

Choose a tag to compare

@oozoofrog oozoofrog released this 13 Nov 16:59

What's New

Hardening for malformed and untrusted input (#13). Still follows the Swift 6.4.2 demangler.

No Traps on Damaged Symbols

Input that cannot be demangled is returned unchanged. These used to crash the process:

  • Truncated old-style symbols ("_TF3", also inside longer text such as "log: _TF3 crashed")
  • Substitution indexes at UInt64.max
  • Reabstraction thunks without children ("$sTR"); they print <null node pointer> like swift-demangle
  • Punycode code points above UInt32.max
  • Deeply nested types, which overflowed the stack

Depth Limits

  • A symbol whose tree is deeper than 256 levels is returned unchanged; for the old _T mangling the limit is 64 nested types. The deepest tree among 1.49 million symbols from Xcode's frameworks has 121 levels.
  • A constant-propagated function inside a function signature specialization is demangled up to 8 symbols deep.
  • With these limits an optimized build demangles any input within a 512 KB thread stack. A debug build needs a larger stack for deep trees.

Behaviour Changes

  • A string that starts with s / S gets the $ prefix only when that makes its leading token demangle. "sorted".demangled is now "sorted" (was "$sorted"); "s4main3fooyyF".demangled still gives main.foo() -> ().
  • Key path index operators and value generic parameters print like swift-demangle: key path index equality operator for (Swift.String), vg.g<let A>(...). Both printed unknown index before.
  • demangling(_:printDebugInformation:) is deprecated and ignores the flag; the library no longer prints to stdout. An unapplied reference such as let f = "x".demangling is now ambiguous and needs a type annotation.

Speed

  • Long symbols demangle in linear time: a 160 KB identifier went from 61 s to 0.03 s, 20,000 repeated Si from 21 s to 0.02 s.

Internal

  • Dead helpers removed; Demangler.swift, OldDemangler.swift, NodePrinter.swift and Node.swift split into smaller files by job.