Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp795037imm; Wed, 26 Sep 2018 06:58:56 -0700 (PDT) X-Google-Smtp-Source: ACcGV63qKMHE8COqQMIB27YupcxgssRlWOkvYDRCXn2omAYehr94aEG7KExwaZReYwjk02bQ22Dr X-Received: by 2002:a17:902:7001:: with SMTP id y1-v6mr6355101plk.259.1537970336061; Wed, 26 Sep 2018 06:58:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537970336; cv=none; d=google.com; s=arc-20160816; b=UY01UT8Q2P1f1K+we8aaIn9fQ970Z0GNiPaZZioePSwvP7ih1XAY0lLMq3F0SgrkQV tIVDN7tcHRCOvzuAdQ5cuo1t1xk9M2WQaLlhI/m7PIihyw6ctA35nSLodJhOS3TSlkmJ Hw4P1j1DDzlaoLnLZrL4ZtlVJr1zfLquvzZcyW4cdncBHQJLhfk2Qw9uPtPAcaWa2vPG d7asmvs1BrHgyWKl301xt92Rx6Xx9vdRwCXIPTISxj9opro/Cpq8cjHsAZhR3XtpY+Y3 wa1CvP0vvgw4+O8rPNfjRAYeJBxhxP3tjSJujlXjjYHyKtgf7zZF5JEqsMCZV70q3YUw m7sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=t0RSj1dZ3Vpus0qZrJ98PkU62Z/n/7Ee9CIcI4Ablbw=; b=zL9eaZocDlebODkeJ1hPVdhpOuRYmCMGnQrIDXq567xvveaX9brC6p9hTMlXAo1Ftu 2ef6F8A4Pa/PJNqnSTuKL4GVzaLd7r62Oq1Rhy3BsGrjWhlz+PYOvS6xRkQuYtKXe5Mm 9iAoEJRAWXGra7pnrhaQeVANu07AmdEmztz2uhq9HkoiIu2y8IMLjWw2ryHPcgFOgB+E gfWN/z1zAqf9zm9M87CgDuSlU+s0RC+mx1U3C7lRLROgdz5j2PvKOVZta26A5c8kN6fJ eWXQja/6SwYq2kL1f4WsyYgi2NTuX2Th5tQJBwcNpHUCSOZpevBg3tDFOMFYL/i4EX/L icTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kdab.com header.s=dkim header.b=tz6WAN3H; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kdab.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n61-v6si5586518plb.497.2018.09.26.06.58.39; Wed, 26 Sep 2018 06:58:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kdab.com header.s=dkim header.b=tz6WAN3H; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kdab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727738AbeIZULc (ORCPT + 99 others); Wed, 26 Sep 2018 16:11:32 -0400 Received: from mail.kdab.com ([176.9.126.58]:32809 "EHLO mail.kdab.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726937AbeIZULb (ORCPT ); Wed, 26 Sep 2018 16:11:31 -0400 Authentication-Results: mail.kdab.com (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=kdab.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kdab.com; h= content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:date:subject:subject:from:from; s=dkim; t= 1537969948; x=1538833949; bh=t0RSj1dZ3Vpus0qZrJ98PkU62Z/n/7Ee9CI cI4Ablbw=; b=tz6WAN3Hm7/v0cjj3nGM/ph1zjnWWDg7QNmEYfc5ExRbenTj4Ha EkUWTq2k7KlMb1AfCXOWyD2lPqRDg7UbtHioXEGKUTvf0ybUcoqtW9QslioOd0tM b40xpTYeZEAIFBc+ZWZX+hdPL3KSzi3IBpZX5XXBkapQu1cYj7wbTmwQ= X-Virus-Scanned: amavisd-new at kdab.com From: Milian Wolff To: acme@kernel.org, jolsa@kernel.org, yao.jin@linux.intel.com, namhyung@kernel.org Cc: Linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Milian Wolff Subject: [PATCH 3/3] perf report: don't crash on invalid inline debug information Date: Wed, 26 Sep 2018 15:52:07 +0200 Message-Id: <20180926135207.30263-3-milian.wolff@kdab.com> In-Reply-To: <20180926135207.30263-1-milian.wolff@kdab.com> References: <20180926135207.30263-1-milian.wolff@kdab.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the function name for an inline frame is invalid, we must not try to demangle this symbol, otherwise we crash with: #0 0x0000555555895c01 in bfd_demangle () #1 0x0000555555823262 in demangle_sym (dso=3D0x555555d92b90, elf_name=3D= 0x0, kmodule=3D0) at util/symbol-elf.c:215 #2 dso__demangle_sym (dso=3Ddso@entry=3D0x555555d92b90, kmodule=3D, kmodule@entry=3D0, elf_name=3Delf_name@entry=3D0x0) at util/sy= mbol-elf.c:400 #3 0x00005555557fef4b in new_inline_sym (funcname=3D0x0, base_sym=3D0x55= 5555d92b90, dso=3D0x555555d92b90) at util/srcline.c:89 #4 inline_list__append_dso_a2l (dso=3Ddso@entry=3D0x555555c7bb00, node=3D= node@entry=3D0x555555e31810, sym=3Dsym@entry=3D0x555555d92b90) at util/sr= cline.c:264 #5 0x00005555557ff27f in addr2line (dso_name=3Ddso_name@entry=3D0x555555= d92430 "/home/milian/.debug/.build-id/f7/186d14bb94f3c6161c010926da66033d= 24fce5/elf", addr=3Daddr@entry=3D2888, file=3Dfile@entry=3D0x0, line=3Dline@entry=3D0x0, dso=3Ddso@entry=3D0x555555c7bb00, unwind_inl= ines=3Dunwind_inlines@entry=3Dtrue, node=3D0x555555e31810, sym=3D0x555555= d92b90) at util/srcline.c:313 #6 0x00005555557ffe7c in addr2inlines (sym=3D0x555555d92b90, dso=3D0x555= 555c7bb00, addr=3D2888, dso_name=3D0x555555d92430 "/home/milian/.debug/.b= uild-id/f7/186d14bb94f3c6161c010926da66033d24fce5/elf") at util/srcline.c:358 So instead handle the case where we get invalid function names for inlined frames and use a fallback '??' function name instead. While this crash was originally reported by Hadrien for rust code, I can now also reproduce it with trivial C++ code. Indeed, it seems like libbfd fails to interpret the debug information for the inline frame symbol name: $ addr2line -e /home/milian/.debug/.build-id/f7/186d14bb94f3c6161c010926d= a66033d24fce5/elf -if b48 main /usr/include/c++/8.2.1/complex:610 ?? /usr/include/c++/8.2.1/complex:618 ?? /usr/include/c++/8.2.1/complex:675 ?? /usr/include/c++/8.2.1/complex:685 main /home/milian/projects/kdab/rnd/hotspot/tests/test-clients/cpp-inlining/ma= in.cpp:39 I've reported this bug upstream and also attached a patch there which should fix this issue: https://sourceware.org/bugzilla/show_bug.cgi?id=3D23715 Signed-off-by: Milian Wolff Cc: Arnaldo Carvalho de Melo Reported-by: Hadrien Grasland --- tools/perf/util/srcline.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c index 09d6746e6ec8..e767c4a9d4d2 100644 --- a/tools/perf/util/srcline.c +++ b/tools/perf/util/srcline.c @@ -85,6 +85,9 @@ static struct symbol *new_inline_sym(struct dso *dso, struct symbol *inline_sym; char *demangled =3D NULL; =20 + if (!funcname) + funcname =3D "??"; + if (dso) { demangled =3D dso__demangle_sym(dso, 0, funcname); if (demangled) --=20 2.19.0