Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2231567rdd; Fri, 12 Jan 2024 03:35:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IFnJrAwE2nBzkSVfxYbEf2Y6/LFEIISrZC9fnYGXaG1PIqzGXcYOUK3WMeKVDzgbc6NxMw1 X-Received: by 2002:a05:6a20:bc90:b0:199:891c:54cb with SMTP id fx16-20020a056a20bc9000b00199891c54cbmr1083168pzb.55.1705059352331; Fri, 12 Jan 2024 03:35:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705059352; cv=none; d=google.com; s=arc-20160816; b=vupW9ODbqx1tLZGCWEXul+12/GtqMeoOpndo5YLQPneWnQDihdO8vALXl7ZmrvNGjt /8u04t6cKhXR6K4qdTilTbV6mOgczKi9zOvqWStJlrlRDDGEEeqojEMKlLXte1xcrPtt NQjJVKDqfzob3TuNkZJQwhoAi4oYOc3tWmAlTAeuFLtLd9FD4AAzt0/fZ3T8DzNfaOPq wAsL+PlKPsqBg/cz8kkCwG1cy/EB1x2XFtLT6+CCzzp2IeWtII7iJm05qoPtcVY+hxim wjG8hXKhMUDOAZGfhTX5Awco6ZCI2uGhlQaSW6fo3AxLyxJ78VWVwCj2xK1siKWFYJE5 U14g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=nufjSq9RSSt5IaRP75QZnyARiucdjCX5fd0H2A9Q7d0=; fh=pHPGx4sooeIsEU6Iq66QuMsljzZHbAKiEf4v00NX2Es=; b=iuYcWiEl1FRJCaW7Z+ZL/1BPKkfGYNs2Zahfeqew7BwchFobprZoudaM+nuLwEKt04 NOOsBsdvxnGk6tyPXt7xcZpQEsi0QJAQNoz/ofyf5Bb3ZK7Bn9mEkM1jt8E62RGXumSc R8RPtOiC4DnFa3ijKsTvHvX2rQO+fT+XW/yKJ0J3r5YdQ40pFLMdoahz+0j9w5B5gIhX TdiDb1jUveLg84AHr6Eir543ecghXwFbwr4YKEAsZaZXO9sMihLLwyETFN46PfKfoipo EHV66uW2VwzFYOte5VEpHdhlrYf0f9Cw1Ba0FsiM62MyCjuEhAB5BMeMloIlxHpA8P59 fmVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-24622-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24622-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ei45-20020a056a0080ed00b006d9b65b8908si2832927pfb.398.2024.01.12.03.35.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 03:35:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24622-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-24622-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24622-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EDED5287960 for ; Fri, 12 Jan 2024 11:35:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0ED7E6A011; Fri, 12 Jan 2024 11:35:33 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 991AA67E92; Fri, 12 Jan 2024 11:35:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 28E771424; Fri, 12 Jan 2024 03:36:16 -0800 (PST) Received: from [192.168.1.100] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 679643F73F; Fri, 12 Jan 2024 03:35:28 -0800 (PST) Message-ID: <2c9f5893-450c-012b-b748-a8fe8ddfae86@arm.com> Date: Fri, 12 Jan 2024 11:35:27 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH] perf data convert: Fix segfault when converting to json on arm64 Content-Language: en-US To: Ilkka Koskinen Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter References: <20240111232923.8138-1-ilkka@os.amperecomputing.com> From: James Clark In-Reply-To: <20240111232923.8138-1-ilkka@os.amperecomputing.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 11/01/2024 23:29, Ilkka Koskinen wrote: > Arm64 doesn't have Model in /proc/cpuinfo and, thus, cpu_desc doesn't get > assigned. > > Running > $ perf data convert --to-json perf.data.json > > ends up calling output_json_string() with NULL pointer, which causes a > segmentation fault. > > Signed-off-by: Ilkka Koskinen > --- > tools/perf/util/data-convert-json.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-convert-json.c > index 5bb3c2ba95ca..5d6de1cef546 100644 > --- a/tools/perf/util/data-convert-json.c > +++ b/tools/perf/util/data-convert-json.c > @@ -97,6 +97,11 @@ static void output_json_format(FILE *out, bool comma, int depth, const char *for > static void output_json_key_string(FILE *out, bool comma, int depth, > const char *key, const char *value) > { > + if (!value) { > + pr_info("No value set for key %s\n", key); > + return; > + } > + > output_json_delimiters(out, comma, depth); > output_json_string(out, key); > fputs(": ", out); It looks like this would hide new errors on any of the other fields that output_json_key_string() is called on. Maybe it would be better to only wrap the call to output cpu_desc with the if? If that's the only one that we think is optional, and even better only do it for arm64. I mention this because the test for 'perf data convert' only checks for valid json syntax, but not any fields. So we might want to avoid others going missing. Thanks James