Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1227441imm; Wed, 17 Oct 2018 15:56:43 -0700 (PDT) X-Google-Smtp-Source: ACcGV62KeHj2CadqcVs0mrgKlqqm5RdvSmvmTwmMbLpt79Mw/pTGBWTlpxOfP2ev5HliiZMjYz4i X-Received: by 2002:a63:7f0e:: with SMTP id a14-v6mr26189046pgd.296.1539817003266; Wed, 17 Oct 2018 15:56:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539817003; cv=none; d=google.com; s=arc-20160816; b=k1ZNR6dm2c/0OJnlp0VxvjIwDOKEo2szw6v78/d/TgcfYDeNO40qBztB1Gi43vOWwW P6qjTIZ2D7eB7QYwXeW/19drdd1C6nX1vUBWSl6xI7gdJqDPxLA/VfGTAea9TyPLIwbV 2QWsU2apK+MvIt94rE1yVozbHsnpu4VQurYx9DQTt2vLHNfs3qROoXf5oMa01hXkf51u UOj+nEWOIdNPr43C/vq9Ba87MRGyV8i+5gG1H4lMgbuMH8RzgvQzRFRD3DiTrRu3MzGG dpCkXGosJ1H6DCmLPj2WMwaLIYwJ0ylNk0vjPyPXjE1quhFt+JINrTIOshonq0DP6q5J ODAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=lHAA2ocCCsTZCf/LgoLJKApanWA0t6Vvdxc65w6iFqo=; b=EJoiBMzzJztIPPDobl4t1rb7W8YgJZAy/9xgfFbEZM/89CX5n2A47GNWLMsPeYIRIv ZZfn+yIDLcrqI4itnOTrOLdvNTQCB6cntI/zFd+EXEpwd/ud0ONkONb+34IOGykFQK59 Cr+gCrULAmgVPZPq96nhRPDbqSBH10aITtpGGOFY6VlRIV7N9GcjykQuJt9O8l+pSGTi /hPQTdhCn6NKbWdQlvA6G3Mv35gSxfbnvFnVyF4lGbavomHIJIn5Ayhkv7W6DCslF7A4 RxqTz+CInvUgoWgT0fSsQm15cFbyc/FW/fhGHM0TAdL6eGZdOEeEW9Ak2ijIasjBlCn1 Cw+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=05g3e98S; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t33-v6si18968091pgk.141.2018.10.17.15.56.28; Wed, 17 Oct 2018 15:56:43 -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=@kernel.org header.s=default header.b=05g3e98S; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727866AbeJRGxp (ORCPT + 99 others); Thu, 18 Oct 2018 02:53:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:42352 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727814AbeJRGxp (ORCPT ); Thu, 18 Oct 2018 02:53:45 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 847C721470; Wed, 17 Oct 2018 22:55:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539816950; bh=oxbSm3kyXdTxbxUh1AeF4emQcTqJgTFdQmsNY408V4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=05g3e98S79CiwJZl+ySdUmLyRE9JexDvo4siKnNMese8M0mUrEIpk/2WaGv4hYw7w HgmSqzyCkZB8OIuRixkuPDj77ow7LhkeLntbAXVfvKbBZKNf4Gol5OxMxx5H3WxkZn OBbAWbC/5Aec3CSf7P5e5p92A6gIx+IyyU+FHAZk= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Milian Wolff , Jin Yao , Jiri Olsa , Namhyung Kim , Arnaldo Carvalho de Melo Subject: [PATCH 09/11] perf report: Don't crash on invalid inline debug information Date: Wed, 17 Oct 2018 19:54:59 -0300 Message-Id: <20181017225501.32150-10-acme@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20181017225501.32150-1-acme@kernel.org> References: <20181017225501.32150-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Milian Wolff 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) -- 2.14.4