Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp16401015rwd; Mon, 26 Jun 2023 09:28:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7XYhFGm1QJx7iQ0aweS+rvi/un3bH1q0U+wj1Dh1kPVVBMRa7d40pXG0fG8pPABUPcayJ4 X-Received: by 2002:a17:903:1210:b0:1ab:d6f:51b0 with SMTP id l16-20020a170903121000b001ab0d6f51b0mr9285268plh.18.1687796911987; Mon, 26 Jun 2023 09:28:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687796911; cv=none; d=google.com; s=arc-20160816; b=QDSLIsDlU1cCEM+9rIGYv0ZZX2GQIOnsaqfxMbZn2+ci7ItNCTKSk95cPeyiNyaO2B uvs+K4hQkQTAJCq5mtXtdyPtvH96zlZTHU6uRey2rPYza7PO8eJxO48TgSQGpErHwdaT DVgJ57PUC/hDefPJUJq3X69bGFfpfctqqUoMPUDUXkUPP4j0B20WATwQraMwYlcAPf3/ mOm9c+mdzx1dSPCIpEF3DuqvDnc4bs3+KtlQUQJZrPKrXVbMcedHxfznhoslZU8rE/Zk lrkvBcZHqeQA8F80p+U7CvFgTGd5mX16B5qNPQ+XEMW4a0m841reOeXYqTaJIL6NHPtL EuZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=zx6zJjer5o7rGi+gvetzVLAWzT5kEXbRQpNFqeC8yCQ=; fh=BH2wu2WC/D8Gb1TvhiNtspnHR3N8TPMNXgmd0sXnIOI=; b=vmIs8oAljajZdydVNFp97Abb8s2HUoKWNGWxPawcP4izyR29cNQt3kPTLt93OHBjgZ rGVWZ3ER9LUwvRFZU0mj2KeLKFKS+Oplz2mRXlRekGM2SXd2UZqaXV4OPwCSbTHKpGCb 4tIOvBKj/FEjYXucJ1mBRtHLXPPZGpxBGyZvufM5HJHesfZlp1zQ/9Ghld6KKbuOYGFL 5tU4fxHGbH0JR2DazB6S5OTBit5xFg4rVWDoR1gquNWrihsbbRGqUY2Hrn/Jii/phzFh 3nu95ttM+s7PWwMRAP4I8Ip0oepYmS7Ms5WhOlUJIGzX3e3t5bsLa5vATz3ot/H8MGXV 4aIg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c13-20020a170902f30d00b001b676f3129fsi3867888ple.394.2023.06.26.09.28.19; Mon, 26 Jun 2023 09:28:31 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231754AbjFZQLU (ORCPT + 99 others); Mon, 26 Jun 2023 12:11:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231737AbjFZQLQ (ORCPT ); Mon, 26 Jun 2023 12:11:16 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A87A5E53; Mon, 26 Jun 2023 09:11:14 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 68E00143D; Mon, 26 Jun 2023 09:11:58 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D39D63F663; Mon, 26 Jun 2023 09:11:11 -0700 (PDT) From: James Clark To: linux-perf-users@vger.kernel.org Cc: James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/2] perf report: Don't add to histogram when there is no thread found Date: Mon, 26 Jun 2023 17:10:58 +0100 Message-Id: <20230626161059.324046-3-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230626161059.324046-1-james.clark@arm.com> References: <20230626161059.324046-1-james.clark@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org thread__find_map() chooses to exit without assigning a thread to the addr_location in some scenarios, for example when there are samples from a guest and perf_guest == false. This results in a segfault when adding to the histogram because it uses unguarded accesses to the thread member of the addr_location. Fix it by exiting early if no thread is set. This fixes the referenced commit when using perf report with Coresight but probably isn't exclusive to that case. Fixes: 8d3031d39fe8 ("perf cs-etm: Track exception level") Signed-off-by: James Clark --- tools/perf/builtin-report.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index dcedfe00f04d..1a2caa4ce5c3 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -293,6 +293,9 @@ static int process_sample_event(struct perf_tool *tool, goto out_put; } + if (!al.thread) + goto out_put; + if (rep->stitch_lbr) thread__set_lbr_stitch_enable(al.thread, true); -- 2.34.1