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 X-Spam-Level: ** X-Spam-Status: No, score=2.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,UNWANTED_LANGUAGE_BODY autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 939EBC1B0F2 for ; Wed, 20 Jun 2018 13:31:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 57A1920872 for ; Wed, 20 Jun 2018 13:31:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 57A1920872 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932481AbeFTNbK (ORCPT ); Wed, 20 Jun 2018 09:31:10 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:37308 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932459AbeFTNbG (ORCPT ); Wed, 20 Jun 2018 09:31:06 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5KDTIeB097032 for ; Wed, 20 Jun 2018 09:31:05 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0b-001b2d01.pphosted.com with ESMTP id 2jqnty63gq-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 Jun 2018 09:31:04 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Jun 2018 14:31:01 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 20 Jun 2018 14:30:56 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5KDUu6w25427980 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 20 Jun 2018 13:30:56 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 25FFD4C052; Wed, 20 Jun 2018 14:21:55 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 817AD4C046; Wed, 20 Jun 2018 14:21:52 +0100 (BST) Received: from bangoria.in.ibm.com (unknown [9.195.33.217]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 20 Jun 2018 14:21:52 +0100 (BST) From: Ravi Bangoria To: acme@kernel.org, jolsa@redhat.com Cc: alexander.shishkin@linux.intel.com, namhyung@kernel.org, dsahern@gmail.com, davidcc@google.com, ak@linux.intel.com, yao.jin@linux.intel.com, linux-kernel@vger.kernel.org, Ravi Bangoria Subject: [PATCH 3/3] perf script: Fix crash because of missing feat_op[] entry Date: Wed, 20 Jun 2018 19:00:30 +0530 X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180620133030.2188-1-ravi.bangoria@linux.ibm.com> References: <20180620133030.2188-1-ravi.bangoria@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18062013-0020-0000-0000-0000029CF73E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18062013-0021-0000-0000-000020E94A4E Message-Id: <20180620133030.2188-4-ravi.bangoria@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-06-20_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806200153 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org perf_event__process_feature() tries to access feat_ops[feat].process which is not defined for feat = HEADER_LAST_FEATURE and thus perf is crashing. Add dummy entry for HEADER_LAST_FEATURE in the feat_ops. Before: # ./perf record -o - ls | ./perf script Segmentation fault (core dumped) After: # ./perf record -o - ls | ./perf script ls 7031 4392.099856: 250000 cpu-clock:uhH: 7f5e0ce7cd60 ls 7031 4392.100355: 250000 cpu-clock:uhH: 7f5e0c706ef7 Signed-off-by: Ravi Bangoria Fixes: 57b5de463925 ("perf report: Support forced leader feature in pipe mode") --- tools/perf/util/header.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 540cd2dcd3e7..de8e3e29d870 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -2555,14 +2555,18 @@ struct feature_ops { } /* feature_ops not implemented: */ +#define write_last_feature NULL + #define print_tracing_data NULL #define print_build_id NULL +#define print_last_feature NULL #define process_branch_stack NULL #define process_stat NULL +#define process_last_feature NULL -static const struct feature_ops feat_ops[HEADER_LAST_FEATURE] = { +static const struct feature_ops feat_ops[HEADER_LAST_FEATURE + 1] = { FEAT_OPN(TRACING_DATA, tracing_data, false), FEAT_OPN(BUILD_ID, build_id, false), FEAT_OPR(HOSTNAME, hostname, false), @@ -2585,6 +2589,7 @@ static const struct feature_ops feat_ops[HEADER_LAST_FEATURE] = { FEAT_OPN(CACHE, cache, true), FEAT_OPR(SAMPLE_TIME, sample_time, false), FEAT_OPR(MEM_TOPOLOGY, mem_topology, true), + FEAT_OPN(LAST_FEATURE, last_feature, false), }; struct header_print_data { -- 2.14.4