From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29009 invoked by alias); 23 Oct 2018 11:20:07 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 28987 invoked by uid 89); 23 Oct 2018 11:20:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-lj1-f195.google.com Received: from mail-lj1-f195.google.com (HELO mail-lj1-f195.google.com) (209.85.208.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 23 Oct 2018 11:20:05 +0000 Received: by mail-lj1-f195.google.com with SMTP id v6-v6so967158ljc.11; Tue, 23 Oct 2018 04:20:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=pQg5xJ2iVtVaaJti8YH6xTtC/kj8tAMfwLCiMQB/O0A=; b=azCZ8HwCKBAcTanRx3glbyxmj63qfdCXHhRJcG6QhTVyyYnZZ4WMaqYQSPrjx33jlv o2bnohGYFKKHEKQdum/exzvVbmezg9Rp4BBcuq7haQ3R34rwcCscXZPmHWBm9jJieHSK 7cdtlHUMMfYmcGc6E+6xp0b/YNVioe/cnOPDbfl/Or+zHTuXtNS68h/48yqzXusWEWgP LAGlgzDye8RrX2qIxk/2QRTVcy+hd9yxL/OiNa+xElvTixaMIzByL4qOclz12OGzjVJh 4RC37XZiNACgU6NMIfzm4Q2eOx7zZmQdc5564M08ZWxsKLhyVWy5Wa9AVBG3M0ASPpKJ toCQ== MIME-Version: 1.0 References: <20170425115827.GX1809@tucnak> <3b197eef-db36-7df9-417e-e17be0616b6c@suse.cz> <3f912b8a-0153-f559-e3fe-489b57800697@redhat.com> <894565dc-5c64-cb9f-8bb4-35ee7035c075@suse.cz> <47548cbc-69c9-d925-a107-891a960a2cd1@suse.cz> <714daf75-8c45-2503-23cc-675a7c258485@suse.cz> <7b6f3ceb-d303-4b45-5740-0f4a0f3059cf@suse.cz> In-Reply-To: <7b6f3ceb-d303-4b45-5740-0f4a0f3059cf@suse.cz> From: Richard Biener Date: Tue, 23 Oct 2018 12:20:00 -0000 Message-ID: Subject: Re: [PATCH] Make __PRETTY_FUNCTION__-like functions mergeable string csts (PR c++/64266). To: =?UTF-8?Q?Martin_Li=C5=A1ka?= Cc: Jason Merrill , Jakub Jelinek , Pedro Alves , Jan Kratochvil , GCC Patches , Segher Boessenkool , wilson@gcc.gnu.org, Nathan Sidwell Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2018-10/txt/msg01419.txt.bz2 On Tue, Oct 23, 2018 at 10:59 AM Martin Li=C5=A1ka wrote: > > Hi. > > I've returned to this long-lasting issue after quite some time. Thanks to= Honza I hope > I can now address the root cause which caused output of a string constant= when debug info > was emitted. The problematic situation happened with following back-trace: > > #0 mergeable_string_section (decl=3D, align= =3D64, flags=3D0) at /home/marxin/Programming/gcc/gcc/varasm.c:808 > #1 0x0000000001779bf3 in default_elf_select_section (decl=3D, reloc=3D0, align=3D64) at /home/marxin/Programming/gcc/gcc= /varasm.c:6739 > #2 0x000000000176efb6 in get_constant_section (exp=3D, align=3D64) at /home/marxin/Programming/gcc/gcc/varasm.c:3302 > #3 0x000000000176f468 in build_constant_desc (exp=3D) at /home/marxin/Programming/gcc/gcc/varasm.c:3371 > #4 0x000000000176f81c in output_constant_def (exp=3D, defer=3D1) at /home/marxin/Programming/gcc/gcc/varasm.c:3434 > #5 0x000000000176d406 in decode_addr_const (exp=3D, value=3D0x7fffffffc540) at /home/marxin/Programming/gcc/gcc/varasm.c:= 2951 > #6 0x000000000176d93f in const_hash_1 (exp=3D)= at /home/marxin/Programming/gcc/gcc/varasm.c:3054 > #7 0x000000000176fdc2 in lookup_constant_def (exp=3D) at /home/marxin/Programming/gcc/gcc/varasm.c:3557 > #8 0x0000000000dd5778 in cst_pool_loc_descr (loc=3D) at /home/marxin/Programming/gcc/gcc/dwarf2out.c:17288 > > That was in situation where we emit debug info of a function that has an = inlined __PRETTY_FUNCTION__ from > a different function. As seen, the constant is output due to const_hash_1= function call. Proper fix would > be to not emit these string constants for purpose of hash function. possibly sth like the following - that avoids all cases of calling output_constant_def. Probably worth testing separately. diff --git a/gcc/varasm.c b/gcc/varasm.c index 91650eea9f7..9121dbd2c84 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -3047,6 +3047,10 @@ const_hash_1 (const tree exp) } case ADDR_EXPR: + if (CONSTANT_CLASS_P (TREE_OPERAND (exp, 0))) + return const_hash_1 (TREE_OPERAND (exp, 0)); + + /* Fallthru. */ case FDESC_EXPR: { struct addr_const value; > However, I still see some minor ICEs, it's probably related to decay_conv= ersion in cp_fname_init: > > 1) ./xg++ -B. /home/marxin/Programming/gcc/gcc/testsuite/g++.dg/cpp0x/lam= bda/lambda-__func__2.C > > /home/marxin/Programming/gcc/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-__f= unc__2.C:6:17: internal compiler error: Segmentation fault > 6 | [] { return __func__; }(); > | ^~~~~~~~ > 0x1344568 crash_signal > /home/marxin/Programming/gcc/gcc/toplev.c:325 > 0x7ffff6bc310f ??? > /usr/src/debug/glibc-2.27-6.1.x86_64/signal/../sysdeps/unix/sysv/= linux/x86_64/sigaction.c:0 > 0x9db134 is_capture_proxy(tree_node*) > /home/marxin/Programming/gcc/gcc/cp/lambda.c:261 > 0xaeecb7 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) > /home/marxin/Programming/gcc/gcc/cp/pt.c:16700 > 0xaee5fd tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) > /home/marxin/Programming/gcc/gcc/cp/pt.c:16636 > 0xaf0ffb tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) > /home/marxin/Programming/gcc/gcc/cp/pt.c:16942 > > where > (gdb) p debug_tree(decl) > type type size > unit-size > align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-t= ype 0x7ffff69b5498 precision:8 min max > pointer_to_this > > unsigned DI > size > unit-size > align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type= 0x7ffff69b5540> > readonly used tree_2 unsigned DI /home/marxin/Programming/gcc/gcc/tes= tsuite/g++.dg/cpp0x/lambda/lambda-__func__2.C:6:17 size unit-size > align:64 warn_if_not_align:0 context > value-expr > constant > arg:0 > constant > arg:0 > constant "operator()\000">>>> > > and > #0 0x00000000009db134 in is_capture_proxy (decl=3D) at /home/m= arxin/Programming/gcc/gcc/cp/lambda.c:261 > > 2 ) ./xg++ -B. /home/marxin/Programming/gcc/gcc/testsuite/g++.dg/ext/pret= ty2.C -c > /home/marxin/Programming/gcc/gcc/testsuite/g++.dg/ext/pretty2.C:16:24: in= ternal compiler error: Segmentation fault > 16 | __PRETTY_FUNCTION__), 0)) > | ^ > /home/marxin/Programming/gcc/gcc/testsuite/g++.dg/ext/pretty2.C:36:10: no= te: in expansion of macro =E2=80=98assert=E2=80=99 > 36 | int a =3D (assert (foo ()), 1); > | ^~~~~~ > 0x1344568 crash_signal > /home/marxin/Programming/gcc/gcc/toplev.c:325 > 0x7ffff6bc310f ??? > /usr/src/debug/glibc-2.27-6.1.x86_64/signal/../sysdeps/unix/sysv/= linux/x86_64/sigaction.c:0 > 0x9db270 is_capture_proxy(tree_node*) > /home/marxin/Programming/gcc/gcc/cp/lambda.c:265 > 0x9dbad9 is_normal_capture_proxy(tree_node*) > /home/marxin/Programming/gcc/gcc/cp/lambda.c:274 > 0x9c1fe6 mark_use(tree_node*, bool, bool, unsigned int, bool) > /home/marxin/Programming/gcc/gcc/cp/expr.c:114 > 0x89d9ab convert_like_real > /home/marxin/Programming/gcc/gcc/cp/call.c:6905 > > where: > > (gdb) p debug_tree(decl) > type type size > unit-size > align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-t= ype 0x7ffff69b4498 precision:8 min max > pointer_to_this > > unsigned type_6 DI > size > unit-size > align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type= 0x7ffff69b4540> > readonly used tree_1 tree_2 unsigned read decl_6 DI /home/marxin/Prog= ramming/gcc/gcc/testsuite/g++.dg/ext/pretty2.C:36:10 size unit-size > align:64 warn_if_not_align:0 > value-expr > constant > arg:0 > constant > arg:0 > constant "top level\000">>> chain > > > Can please a C++ maintainer help me with that? Having that I hope I can f= inish the patch. > > Thank you, > Martin