https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118927

--- Comment #6 from Nate Eldredge <nate at thatsmathematics dot com> ---
After some brief digging, it seems like the problem is that
`cxx_printable_name_internal` can be called recursively by `lang_decl_name'
(via `announce_function').  This is bad because, with its static ring buffer,
it's not reentrant.  In particular, at the site of the call to `lang_decl_name`
(https://github.com/gcc-mirror/gcc/blame/427386042f056a2910882bf0c632b4db68c52bbb/gcc/cp/tree.cc#L2770),
the ring buffer is in an inconsistent state, as one of its entries has just
been freed but not marked as invalid.  So a recursive call may think that entry
is valid, and decide to free it again to make room for a new one.

The ring buffer design seems problematic under the circumstances.  Is caching
the printable name really an important optimization?  If so, then maybe a less
primitive caching structure, with more sensible lifetime management, would be
appropriate.

Reply via email to