Message ID | ZN4Q2rxxsL08A8rd@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp701813vqi; Thu, 17 Aug 2023 06:32:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDXEaGwzQQuy8PpA1WZDBwmJkkiZ8WWbEIwCmhvvpcA2nRkYXOTztyN1u/QQhlH15shh3o X-Received: by 2002:a17:902:e54f:b0:1b8:9552:ca with SMTP id n15-20020a170902e54f00b001b8955200camr5913476plf.45.1692279127162; Thu, 17 Aug 2023 06:32:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692279127; cv=none; d=google.com; s=arc-20160816; b=vUe7j6/ooUlvGvKftfLYtSxBpbdcyTQ0gsxGQoy3b/AWhqq9OyAq/WFDh+ek10dGHD NIqxXv5ZCYzqXEu48oMkvvYXbAKNObUAcAka9tVKLDH/riaADBeJ8GNYfgEaa08xgd6Z nlHljOjQjNCAfKLPjc5DTSvYhUdl3Eb7ZuB8Symnk6i+HFLkphwlAJRwXJ3UpAKrox/3 Fna5l28K7RsHjXFGIFOrToT3ZdXPve5WfMwA7l26FSv96vt6wsaChsHOW/3vYWTFlhQT xJfNZ8F0+wkH2kahNEAPxV8/QUcB2DrgC+U03d26WBBvNOMuL3Hn9HUGnnczO3kTQT3u T9Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=ETJqkPJ+qVyXB/cynF7ySE29Dvh7JtgdibRCYW+a7/4=; fh=HrxbOB1bUiHGZ0ffCUWnDcf7NQAOq+sUdp5qoTVvraE=; b=muI+Lw2RXBpWfceXoXmyU3lwQ0atuDP3xX129iHNb1ptR5ChbiqgDDyv4e5xJVHt8F cx/+xL1GcS/WJ8lNcCzU6Trro3xEt0OVOEWtbYvqfmnDYrEFRcB80qVyxqnDGcWcYMqt iOeyNBvhb0ikPSCn+fV20+d0SX0ClDRl80hBsM6PaRkMVvcCSvCBzvjDqy520/e9hEcy jMLMZ/m5vBMp3ujN6483B3m/b4Psbw3SWcjvX+4/VN/bxG4BHEInhywoN6v/zFjZMnCz p09Kt2Xx7i+iExmBWSRJ6OIYqy6KtHTvMR2Ed3fSiKlUsWlHgfLgvecpSiBvMFNrMwyy z8ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=acr764nD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z17-20020a170903019100b001b9be39eaa8si13929939plg.348.2023.08.17.06.31.53; Thu, 17 Aug 2023 06:32:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=acr764nD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1350743AbjHQMWZ (ORCPT <rfc822;somadevkernel@gmail.com> + 99 others); Thu, 17 Aug 2023 08:22:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350915AbjHQMWN (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 17 Aug 2023 08:22:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE89F2713 for <linux-kernel@vger.kernel.org>; Thu, 17 Aug 2023 05:21:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B82FF63A55 for <linux-kernel@vger.kernel.org>; Thu, 17 Aug 2023 12:21:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D87D4C433C8; Thu, 17 Aug 2023 12:21:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692274910; bh=2B5Gj22+SKs//miCvu0ePsQRQsA989iiI/oiqI9LnYg=; h=Date:From:To:Cc:Subject:From; b=acr764nD/rpRcvPBiF4ZktYYy81eadQ2fJSzxhP4uuCgPAxyxod0EKmWNXJXizD9d cBq7KfnxQK/RnPvuut7Xxodgj4rMOpOFwWrhpj0nxigKH+zc07Mj91H72chdNO3Ajg yfTOSrmfQNpP2Ix2eqO84eGZ2t+nqGkWKUGvGHW6DNVsBRrJhgVLNezT0weo2b7tPj IFK/ORZfZY+usd35x+Sps4DZLwkksH7OuxqAJ+mMBzG0pwS8S/Svs8+NI1ckCbMLRs Br1RcTMxMDtibMi03nQIsi6V1NyEiCfTk/Lu+le4wmfQ0Jqrmku+UeCL/GZNiC7NvO B/jkieXYPGlKw== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id B2529404DF; Thu, 17 Aug 2023 09:21:46 -0300 (-03) Date: Thu, 17 Aug 2023 09:21:46 -0300 From: Arnaldo Carvalho de Melo <acme@kernel.org> To: Namhyung Kim <namhyung@kernel.org>, Mamatha Inamdar <mamatha4@linux.vnet.ibm.com> Cc: Adrian Hunter <adrian.hunter@intel.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Alexey Budankov <alexey.budankov@linux.intel.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jeremie Galarneau <jeremie.galarneau@efficios.com>, Jiri Olsa <jolsa@kernel.org>, Kate Stewart <kstewart@linuxfoundation.org>, Mukesh Ojha <mojha@codeaurora.org>, Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>, Peter Zijlstra <peterz@infradead.org>, Ravi Bangoria <ravi.bangoria@linux.ibm.com>, Shawn Landden <shawn@git.icu>, Song Liu <songliubraving@fb.com>, Thomas Gleixner <tglx@linutronix.de>, Tzvetomir Stoyanov <tstoyanov@vmware.com>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org> Subject: [PATCH 1/1] perf top: Don't pass an ERR_PTR() directly to perf_session__delete() Message-ID: <ZN4Q2rxxsL08A8rd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774483278196205549 X-GMAIL-MSGID: 1774483278196205549 |
Series |
[1/1] perf top: Don't pass an ERR_PTR() directly to perf_session__delete()
|
|
Commit Message
Arnaldo Carvalho de Melo
Aug. 17, 2023, 12:21 p.m. UTC
While debugging a segfault on 'perf lock contention' without an
available perf.data file I noticed that it was basically calling:
perf_session__delete(ERR_PTR(-1))
Resulting in:
(gdb) run lock contention
Starting program: /root/bin/perf lock contention
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
failed to open perf.data: No such file or directory (try 'perf record' first)
Initializing perf session failed
Program received signal SIGSEGV, Segmentation fault.
0x00000000005e7515 in auxtrace__free (session=0xffffffffffffffff) at util/auxtrace.c:2858
2858 if (!session->auxtrace)
(gdb) p session
$1 = (struct perf_session *) 0xffffffffffffffff
(gdb) bt
#0 0x00000000005e7515 in auxtrace__free (session=0xffffffffffffffff) at util/auxtrace.c:2858
#1 0x000000000057bb4d in perf_session__delete (session=0xffffffffffffffff) at util/session.c:300
#2 0x000000000047c421 in __cmd_contention (argc=0, argv=0x7fffffffe200) at builtin-lock.c:2161
#3 0x000000000047dc95 in cmd_lock (argc=0, argv=0x7fffffffe200) at builtin-lock.c:2604
#4 0x0000000000501466 in run_builtin (p=0xe597a8 <commands+552>, argc=2, argv=0x7fffffffe200) at perf.c:322
#5 0x00000000005016d5 in handle_internal_command (argc=2, argv=0x7fffffffe200) at perf.c:375
#6 0x0000000000501824 in run_argv (argcp=0x7fffffffe02c, argv=0x7fffffffe020) at perf.c:419
#7 0x0000000000501b11 in main (argc=2, argv=0x7fffffffe200) at perf.c:535
(gdb)
So just set it to NULL after using PTR_ERR(session) to decode the error
as perf_session__delete(NULL) is supported.
Fixes: 6ef81c55a2b6584c ("perf session: Return error code for perf_session__new() function on failure")
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com>
Cc: Mukesh Ojha <mojha@codeaurora.org>
Cc: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Cc: Shawn Landden <shawn@git.icu>
Cc: Song Liu <songliubraving@fb.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tzvetomir Stoyanov <tstoyanov@vmware.com>
Link: https://lore.kernel.org/lkml/
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-top.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 1baa2acb3cedd989..ea8c7eca5eeedd76 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -1805,6 +1805,7 @@ int cmd_top(int argc, const char **argv) top.session = perf_session__new(NULL, NULL); if (IS_ERR(top.session)) { status = PTR_ERR(top.session); + top.session = NULL; goto out_delete_evlist; }