Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1544814imm; Wed, 17 Oct 2018 23:24:20 -0700 (PDT) X-Google-Smtp-Source: ACcGV61MdA1fd2zR2TnDKLgBqd263hs7vGNCH7CTvCwbOxnBdEfSNspDQQsst4sPp4efndUB8pgI X-Received: by 2002:a62:b209:: with SMTP id x9-v6mr30058718pfe.148.1539843860705; Wed, 17 Oct 2018 23:24:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539843860; cv=none; d=google.com; s=arc-20160816; b=VlyQ2UphONyyJnS+i6zU5Z9awZu+aGOKVnqADQWddgfeULGcqZ9pZEpST6Jr5Ek2CE FyIsoV+WFhKcu9UGAmiFxwoPjZAtlmrwpsLZm3uEg31jdJ0foxddC0U4PzS8SPf/pANz +BNG5iOkofqWjkcWOJ2QrQbRBoCavdv+W334aHYzce+0PWQd5wJSaLUG0rp2RJHXyZW0 fBwPEwoqMrfvlkTFGhyyGcf1fUZuhDKistjqhVXu/fofZgRigRUpc/H0tExA4lYouwwV rRhbvy1ztZhJmJfLRvwLpjKj1K95o+SmHrU/h8TuP8czKRHRk0QqQ6MGm12ykyMxXzQd WhBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=GJhMvfriyJljew0FEFyIRTWYpt8/YR5H+/sRPAZ5+44=; b=IrJW9x+pXyTzlvtflBhqyho/IlvzZmzyufBU1RqSnCCHtZ9wxorIV7LS7B1eSGlmNm DCeVv0M8ChVA3xk24/AlOVMEaKB00YxyznG+OsCzf1T8qOgJXQB3GiCTqJtyQU6sbZ6w TQqe2RdFBEjHj8G3Ia2DiChfhAZF7OwxdW0uaec+EHD3ZqGlEK7w/WI/Trr3zzDECvAc 8PG+BYjZopVb/g91ubc3+husNnnkKeY9jey6jEIHTE3q+SUaEsXsT2j3kb+ypjO+mziU 0p4X3MWBv+sBMoBzYYKh34/s2CJQcbacFVgSnH9oEZkmsOjXJLYdQcv7NU9f9Aui6YQN 461A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w6-v6si20802384pgw.316.2018.10.17.23.24.04; Wed, 17 Oct 2018 23:24:20 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727531AbeJROUu (ORCPT + 99 others); Thu, 18 Oct 2018 10:20:50 -0400 Received: from terminus.zytor.com ([198.137.202.136]:52407 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727331AbeJROUu (ORCPT ); Thu, 18 Oct 2018 10:20:50 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w9I6KCnX708052 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 17 Oct 2018 23:20:12 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w9I6KBfq708049; Wed, 17 Oct 2018 23:20:11 -0700 Date: Wed, 17 Oct 2018 23:20:11 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Milian Wolff Message-ID: Cc: hpa@zytor.com, grasland@lal.in2p3.fr, acme@redhat.com, yao.jin@linux.intel.com, namhyung@kernel.org, tglx@linutronix.de, mingo@kernel.org, jolsa@kernel.org, milian.wolff@kdab.com, linux-kernel@vger.kernel.org Reply-To: acme@redhat.com, yao.jin@linux.intel.com, grasland@lal.in2p3.fr, hpa@zytor.com, milian.wolff@kdab.com, linux-kernel@vger.kernel.org, jolsa@kernel.org, mingo@kernel.org, tglx@linutronix.de, namhyung@kernel.org In-Reply-To: <20180926135207.30263-3-milian.wolff@kdab.com> References: <20180926135207.30263-3-milian.wolff@kdab.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf report: Don't crash on invalid inline debug information Git-Commit-ID: d4046e8e17b9f378cb861982ef71c63911b5dff3 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: d4046e8e17b9f378cb861982ef71c63911b5dff3 Gitweb: https://git.kernel.org/tip/d4046e8e17b9f378cb861982ef71c63911b5dff3 Author: Milian Wolff AuthorDate: Wed, 26 Sep 2018 15:52:07 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 16 Oct 2018 14:52:21 -0300 perf report: Don't crash on invalid inline debug information 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=0x555555d92b90, elf_name=0x0, kmodule=0) at util/symbol-elf.c:215 #2 dso__demangle_sym (dso=dso@entry=0x555555d92b90, kmodule=, kmodule@entry=0, elf_name=elf_name@entry=0x0) at util/symbol-elf.c:400 #3 0x00005555557fef4b in new_inline_sym (funcname=0x0, base_sym=0x555555d92b90, dso=0x555555d92b90) at util/srcline.c:89 #4 inline_list__append_dso_a2l (dso=dso@entry=0x555555c7bb00, node=node@entry=0x555555e31810, sym=sym@entry=0x555555d92b90) at util/srcline.c:264 #5 0x00005555557ff27f in addr2line (dso_name=dso_name@entry=0x555555d92430 "/home/milian/.debug/.build-id/f7/186d14bb94f3c6161c010926da66033d24fce5/elf", addr=addr@entry=2888, file=file@entry=0x0, line=line@entry=0x0, dso=dso@entry=0x555555c7bb00, unwind_inlines=unwind_inlines@entry=true, node=0x555555e31810, sym=0x555555d92b90) at util/srcline.c:313 #6 0x00005555557ffe7c in addr2inlines (sym=0x555555d92b90, dso=0x555555c7bb00, addr=2888, dso_name=0x555555d92430 "/home/milian/.debug/.build-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/186d14bb94f3c6161c010926da66033d24fce5/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/main.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=23715 Reported-by: Hadrien Grasland Signed-off-by: Milian Wolff Cc: Jin Yao Cc: Jiri Olsa Cc: Namhyung Kim Fixes: a64489c56c30 ("perf report: Find the inline stack for a given address") [ The above 'Fixes:' cset is where originally the problem was introduced, i.e. using a2l->funcname without checking if it is NULL, but this current patch fixes the current codebase, i.e. multiple csets were applied after a64489c56c30 before the problem was reported by Hadrien ] Link: http://lkml.kernel.org/r/20180926135207.30263-3-milian.wolff@kdab.com Signed-off-by: Arnaldo Carvalho de Melo --- 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 = NULL; + if (!funcname) + funcname = "??"; + if (dso) { demangled = dso__demangle_sym(dso, 0, funcname); if (demangled)