Bug 17157 - GDB segfault when demangling symbol
Summary: GDB segfault when demangling symbol
Status: RESOLVED MOVED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 7.7
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-14 18:24 UTC by sourceware
Modified: 2024-01-02 16:18 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Repro-Case (242 bytes, text/x-csrc)
2014-07-14 18:24 UTC, sourceware
Details

Note You need to log in before you can comment on or make changes to this bug.
Description sourceware 2014-07-14 18:24:01 UTC
Created attachment 7712 [details]
Repro-Case

The following symbol fails to demangle with GDB 7.7.1 (built from source.) Comes from Code compiled with GCC 4.8.2 on Ubuntu 14.04. Also fails on distro-provided GDB (7.7.)

"_ZNK5niven5ColorIfLi4EEdvIfEENSt9enable_ifIXsrSt13is_arithmeticIT_E5valueEKNS0_IDTmlcvS5__Ecvf_EELi4EEEE4typeES5_"

c++filt correctly demangles this to:

std::enable_if<std::is_arithmetic<float>::value, niven::Color<decltype (((float)())*((float)())), 4> const>::type niven::Color<float, 4>::operator/<float>(float) const

For the repro-case, assuming it has been put into the GDB source root directory and GDB is built, use: gcc -Iinclude/ test.c ./libiberty/libiberty.a -o test
Comment 1 Gary Benson 2014-07-15 08:39:47 UTC
Confirmed and filed as:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61805
Comment 2 sourceware 2014-12-12 20:08:36 UTC
Ok, this problem is a bit more complicated. First, a newer GCC (4.9.1) and Clang 3.5 doesn't produce the symbol any more. Running a more recent c++filt on it now crashes c++filt -- if you look closely, the originally demangled type was also incorrect, as: decltype (((float)()*(float)())) does not make sense -- should have been decltype (float ()*float ()) which is simply float.

I'm debugging a new crash now where the demangler/libiberty starts producing a symbol name with decltype in it, which I strongly suspect is similar to the original issue. Am I right to assume that decltype is never part of a mangled symbol name?
Comment 3 Gary Benson 2014-12-19 13:04:47 UTC
It might be best to add your comments to the GCC bug above, it's more likely to be seen by those with the right kind of expertise.
Comment 4 Hannes Domani 2024-01-02 16:18:23 UTC
Was fixed on gcc side some time ago.