Bug 67738 - libiberty cannot demangle symbol
Summary: libiberty cannot demangle symbol
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: demangler (show other bugs)
Version: 6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-28 05:39 UTC by Robert Schiele
Modified: 2016-12-18 22:35 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-09-28 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Schiele 2015-09-28 05:39:09 UTC
Trying to demangle the symbol _ZNK6Common15ConvertingRangeIN5boost12range_detail17transformed_rangeIZN1a1b1cEbEUljE_KSt6vectorIjSaIjEEEEEcvT_IS7_INS4_1dESaISF_EEEEv causes an infinite recursion in libiberty/cp-demangle.c that finally leads to SIGSEGV once the stack is exhausted.

This issue was introduced with

commit f89ffc3b24e78dd4c9706bc3502941cf08edd56d
Author: ccoutant <ccoutant@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Fri Nov 22 22:25:49 2013 +0000

    Fix demangler to handle conversion operators correctly.

    libiberty/
        PR other/59195
        * cp-demangle.c (struct d_info_checkpoint): New struct.
        (struct d_print_info): Add current_template field.
        (d_operator_name): Set flag when processing a conversion
        operator.
        (cplus_demangle_type): When processing <template-args> for
        a conversion operator, backtrack if necessary.
        (d_expression_1): Renamed from d_expression.
        (d_expression): New wrapper around d_expression_1.
        (d_checkpoint): New function.
        (d_backtrack): New function.
        (d_print_init): Initialize current_template.
        (d_print_comp): Set current_template.
        (d_print_cast): Put current_template in scope for
        printing conversion operator name.
        (cplus_demangle_init_info): Initialize is_expression and
        is_conversion.
        * cp-demangle.h (struct d_info): Add is_expression and
        is_conversion fields.
        * testsuite/demangle-expected: New test cases.


    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205292 138bc75d-0d04-0410-961f-82ee72b054a4

Before that patch was applied this symbol resolved to:

Common::ConvertingRange<boost::range_detail::transformed_range<a::b::c(bool)::{lambda(unsigned int)#1}, std::vector<unsigned int, std::allocator<unsigned int> > const> >::operator a::b::c(bool)::{lambda(unsigned int)#1}<a::d, std::allocator<a::d> ><a::b::c(bool)::{lambda(unsigned int)#1}<a::d, std::allocator<a::d> > >() const

The infinite recursion this is causing is:

[... recursion ongoing ...]
#32659 0x000000000040890a in d_print_comp (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc160)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5424
#32660 0x0000000000409397 in d_print_conversion (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc178)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5819
#32661 0x00000000004079fb in d_print_comp_inner (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc178)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5062
#32662 0x000000000040890a in d_print_comp (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc178)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5424
#32663 0x000000000040623b in d_print_comp_inner (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc190)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:4397
#32664 0x000000000040890a in d_print_comp (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc190)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5424
#32665 0x00000000004068ce in d_print_comp_inner (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc160)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:4593
#32666 0x000000000040890a in d_print_comp (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc160)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5424
#32667 0x0000000000409397 in d_print_conversion (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc178)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5819
#32668 0x00000000004079fb in d_print_comp_inner (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc178)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5062
#32669 0x000000000040890a in d_print_comp (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc178)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5424
#32670 0x000000000040623b in d_print_comp_inner (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc190)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:4397
#32671 0x000000000040890a in d_print_comp (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc190)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5424
#32672 0x00000000004068ce in d_print_comp_inner (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc160)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:4593
#32673 0x000000000040890a in d_print_comp (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc160)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5424
#32674 0x0000000000409397 in d_print_conversion (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc178)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5819
#32675 0x00000000004079fb in d_print_comp_inner (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc178)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5062
#32676 0x000000000040890a in d_print_comp (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc178)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5424
#32677 0x000000000040623b in d_print_comp_inner (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc190)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:4397
#32678 0x000000000040890a in d_print_comp (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc190)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5424
#32679 0x00000000004068ce in d_print_comp_inner (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc160)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:4593
#32680 0x000000000040890a in d_print_comp (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc160)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5424
#32681 0x0000000000409397 in d_print_conversion (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc178)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5819
#32682 0x00000000004079fb in d_print_comp_inner (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc178)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5062
#32683 0x000000000040890a in d_print_comp (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc178)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5424
#32684 0x000000000040623b in d_print_comp_inner (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc190)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:4397
#32685 0x000000000040890a in d_print_comp (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc190)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5424
#32686 0x0000000000407750 in d_print_comp_inner (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc220)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5006
#32687 0x000000000040890a in d_print_comp (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc220)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5424
#32688 0x00000000004067b3 in d_print_comp_inner (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc238)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:4557
#32689 0x000000000040890a in d_print_comp (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc238)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5424
#32690 0x0000000000407750 in d_print_comp_inner (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc250)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5006
#32691 0x000000000040890a in d_print_comp (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc250)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5424
#32692 0x00000000004077e9 in d_print_comp_inner (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc1d8)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5018
#32693 0x000000000040890a in d_print_comp (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc1d8)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5424
#32694 0x00000000004067b3 in d_print_comp_inner (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc268)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:4557
#32695 0x000000000040890a in d_print_comp (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc268)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5424
#32696 0x00000000004068ce in d_print_comp_inner (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc160)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:4593
#32697 0x000000000040890a in d_print_comp (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc160)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5424
#32698 0x0000000000409397 in d_print_conversion (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc178)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5819
#32699 0x00000000004079fb in d_print_comp_inner (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc178)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5062
#32700 0x000000000040890a in d_print_comp (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc178)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5424
#32701 0x000000000040623b in d_print_comp_inner (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc190)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:4397
#32702 0x000000000040890a in d_print_comp (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc190)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5424
#32703 0x0000000000406756 in d_print_comp_inner (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc298)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:4553
#32704 0x000000000040890a in d_print_comp (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc298)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5424
#32705 0x0000000000408fb1 in d_print_mod (dpi=0x7fffffffb790, options=259, mod=0x7fffffffc298)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5637
#32706 0x0000000000408d8c in d_print_mod_list (dpi=0x7fffffffb790, options=259, mods=0x7fffffffb530, suffix=0)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5566
#32707 0x00000000004090e3 in d_print_function_type (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc2e0, mods=0x7fffffffb530)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5707
#32708 0x0000000000407385 in d_print_comp_inner (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc2e0)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:4891
#32709 0x000000000040890a in d_print_comp (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc2e0)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5424
#32710 0x00000000004065b4 in d_print_comp_inner (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc2f8)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:4498
#32711 0x000000000040890a in d_print_comp (dpi=0x7fffffffb790, options=259, dc=0x7fffffffc2f8)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5424
#32712 0x0000000000405ae7 in cplus_demangle_print_callback (options=259, dc=0x7fffffffc2f8, callback=0x4054be <d_growable_string_callback_adapter>,
    opaque=0x7fffffffd820) at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:4119
#32713 0x0000000000409904 in d_demangle_callback (
    mangled=0x409e08 "_ZNK6Common15ConvertingRangeIN5boost12range_detail17transformed_rangeIZN1a1b1cEbEUljE_KSt6vectorIjSaIjEEEEEcvT_IS7_INS4_1dESaISF_EEEEv",
    options=259, callback=0x4054be <d_growable_string_callback_adapter>, opaque=0x7fffffffd820)
    at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5963
#32714 0x0000000000409966 in d_demangle (
    mangled=0x409e08 "_ZNK6Common15ConvertingRangeIN5boost12range_detail17transformed_rangeIZN1a1b1cEbEUljE_KSt6vectorIjSaIjEEEEEcvT_IS7_INS4_1dESaISF_EEEEv",
    options=259, palc=0x7fffffffd878) at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:5984
#32715 0x00000000004099d0 in cplus_demangle_v3 (
    mangled=0x409e08 "_ZNK6Common15ConvertingRangeIN5boost12range_detail17transformed_rangeIZN1a1b1cEbEUljE_KSt6vectorIjSaIjEEEEEcvT_IS7_INS4_1dESaISF_EEEEv",
    options=259) at /home/rschiele/l/pkg/builds/x86_64-pc-linux-gnu/gdb64/srcdir/src/libiberty/cp-demangle.c:6141

While it looks a bit similar to #61321 it should be noted that the patch that is proposed to that one does not fix the issue we are seeing here. Actually the above stack trace is already with this proposed patch applied on top of current gcc trunk.
Comment 1 Mikhail Maltsev 2015-09-28 06:26:23 UTC
Reduced testcase: _ZN1A1BIN1C1D1EIZN1a1b1cEEUljE_K1FI1AEEEEcvT_IIISF_EEEE
Likely a dup of PR 61321.
Comment 2 Mikhail Maltsev 2015-09-28 06:28:14 UTC
Oops, sorry, did not notice your comment about PR 61321
Comment 3 Robert Schiele 2016-11-08 07:38:20 UTC
Solved with the patch https://gcc.gnu.org/ml/gcc-patches/2016-05/msg00105.html proposed for PR70909.

*** This bug has been marked as a duplicate of bug 70909 ***
Comment 4 Mark Wielaard 2016-12-04 23:22:56 UTC
The patch proposed form bug 70909 does prevent the infinite recursion, but that doesn't help demangling the symbol. See the comments in bug #70909 which suggest the demangling should be: