+#ifdef FOLLY_DEMANGLE_MAX_SYMBOL_SIZE
+ // GCC's __cxa_demangle() uses on-stack data structures for the
+ // parser state which are linear in the number of components of the
+ // symbol. For extremely long symbols, this can cause a stack
+ // overflow. We set an arbitrary symbol length limit above which we
+ // just return the mangled name.
+ size_t mangledLen = strlen(name);
+ if (mangledLen > FOLLY_DEMANGLE_MAX_SYMBOL_SIZE) {
+ return fbstring(name, mangledLen);
+ }
+#endif
+