From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98AD4C433FE for ; Wed, 2 Nov 2022 00:04:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229487AbiKBAEF (ORCPT ); Tue, 1 Nov 2022 20:04:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbiKBAEF (ORCPT ); Tue, 1 Nov 2022 20:04:05 -0400 Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCC7CCE6; Tue, 1 Nov 2022 17:04:03 -0700 (PDT) Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-13c2cfd1126so18621517fac.10; Tue, 01 Nov 2022 17:04:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=sRe4Rhg+AzQ1C8960wXYonENiHb2NOvfma+pJy2edvA=; b=u2T4eS6MeB8AjRZLB0FAmEZgb5u5aoVI9souGYuhrkE+Cve2nUG2qjE8aPxm1zsRnt awUypBGKSm6s/me62C9lLXHEt0sqFQRWt+6/8E3PyrBhzie4RL4Npb6l+f1DlHpn2VyD Eg6qO4wIFsz1VCSYuQGe+ORvEQF9oQl5p4yHpD7JkI0HLAGPpIZAc81Dajsq7ZkdfnAi kiNVvp3xZ3NICVwgrLErnaLWme8pZ74PZaRLB8eTzVkoZ6K3hW8oyGwwk0CUJqP7UOUd 0zcUcV85M6THp3o2L4jnpVOktoo2J1ma7yRNLyyQhzxtp4eOGLCM2wfjp3Wf155VRzvb 9f9Q== X-Gm-Message-State: ACrzQf32osLOsVh1uE77nb2ZWMb+k1+/z73yx7hCE1120rhhmBVgN+Wk 2LbKvhghbDTCoSHqH/MSoWg2+5Fv3sPkQMY7UyrVQlGs X-Google-Smtp-Source: AMsMyM6ChSMuBRK6j4CncDwXG+bn2htdD9iQH62m7TfMQ1M8+hUcqoVh0iMamhCUVlpw5QQzi1IUm6VFZ327A9jPEcs= X-Received: by 2002:a05:6870:d18f:b0:13b:a366:f448 with SMTP id a15-20020a056870d18f00b0013ba366f448mr12277351oac.209.1667347442908; Tue, 01 Nov 2022 17:04:02 -0700 (PDT) MIME-Version: 1.0 References: <166731050151.2100653.8202870942871353491.stgit@devnote3> In-Reply-To: <166731050151.2100653.8202870942871353491.stgit@devnote3> From: Namhyung Kim Date: Tue, 1 Nov 2022 17:03:51 -0700 Message-ID: Subject: Re: [PATCH v2 0/3] tools/perf: Fix perf probe crash by clang DWARF5 file To: "Masami Hiramatsu (Google)" Cc: Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Steven Rostedt Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-perf-users@vger.kernel.org Hi Masami, On Tue, Nov 1, 2022 at 6:48 AM Masami Hiramatsu (Google) wrote: > > Hi, > > Here is the 2nd version of the patches for perf probe which improves the > robustness against clang DWARF5 file. > > Since the Clang generates a bit different DWARF5 file, the perf probe > crashes or failes to analyze it. There are actually fragile code against > it, so I fixed it ([1/3]) to avoid crash by SEGV. And make it accepts > Clang's DWARF5 file ([2/3],[3/3]). > > Without this series, the perf probe crashes with the DWARF5 file > which generated by clang as below; > > $ ./perf probe -k $BIN_PATH/vmlinux -s $SRC_PATH -L vfs_read:10 > Segmentation fault > > This series fixes it to handle such file correctly; > > $ ./perf probe -k $BIN_PATH/vmlinux -s $SRC_PATH -L vfs_read:10 > > > 11 ret = rw_verify_area(READ, file, pos, count); > 12 if (ret) > return ret; > > > On the DWARF5 specification, Sec 2.14, there is > "The value 0 indicates that no source file has been specified." > for DW_AT_decl_file, but clang generated DWARF5 will use the value 0. > > This issue is discussed on DWARF std ML; > https://www.mail-archive.com/dwarf-discuss@lists.dwarfstd.org/msg00884.html > > And suggested that removing this part from the specification. > http://wiki.dwarfstd.org/index.php?title=DWARF5_Line_Table_File_Numbers > > So as far as I understand, this is out of standard at this moment, > but the standard itself has a discussion on this part. And maybe updated > as currently clang does in the next release/revision. > > Thank you, > > --- > > Masami Hiramatsu (Google) (3): > tools/perf: Fix to avoid crashing if DW_AT_decl_file is NULL > tools/perf: Fix to use dwarf_attr_integrate for generic attr accessor > tools/perf: Fix to get declared file name from clang DWARF5 Acked-by: Namhyung Kim Thanks, Namhyung > > > tools/perf/util/dwarf-aux.c | 58 ++++++++++++++++++++++++++++------------ > tools/perf/util/dwarf-aux.h | 3 ++ > tools/perf/util/probe-finder.c | 37 +++++++++++++++++--------- > 3 files changed, 68 insertions(+), 30 deletions(-) > > -- > Masami Hiramatsu (Google)