Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp46237rdb; Tue, 16 Jan 2024 14:33:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGSRzEfLESukf5t5CDkZMU3aEAHdQttunCqn3fMmkpRfY9bXKCT4j2DDNoq/xvEH79t4xSy X-Received: by 2002:a05:6902:2687:b0:dbe:9c84:691 with SMTP id dx7-20020a056902268700b00dbe9c840691mr4703512ybb.62.1705444410392; Tue, 16 Jan 2024 14:33:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705444410; cv=pass; d=google.com; s=arc-20160816; b=bvSD4cYBgAijSk2gb6z8ynH9szYlG0dHreyPJYxFy49OqwGoeTgfcaEBjYbirDA6Ti I3cED7boCXOW7KcmQGeM9kzw2ilCa5ikLr+O2uiUVP7aqEqq1bFhc+MdbP1Es3bfMH6n ZBth/DMYDes5UnnF0TWlHIQGM7G5UB1C3m2owk4jg4j0qaTDTtJlvyn2rH8Vx4odn0Jq wrjiJFNlpWBlT4rdriZhfosivb1B9TSncaW7rM8zuLDiHfCA/mLgEAjodvPcDjcZSMID ttSNbHkLBg9NuFfH+mRUVArCz/jvGbJbwQpouY+Z0LM3qz9/1k7SgKG0btsmlPKQiM2v f6Gw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=P00sqh0pFFh48+YMUrZPqOjo0LVvWK+WBACLbeRVv8E=; fh=YJoAkUDvdVi7E/goLDm1PvabyaNyo8262FEMhGBBkOI=; b=JHNr1OgVIVkuPEZZNj0+hvDNHNpANoBJi4DD2a72nDMHsUoAss7r+4ihIPMU07VEgZ VmAHdz+RY2KizL9g5P5RV1ea6bIlDa3d2qSASdn8H1YOJo+8t2o2UrkdBbmFx7WLT3ZI GR5lhWcyjcNkL3zggB6vN3241y8YU19pwLh1Knci+5Jtbr4/oIqtwlaRQHY8xiTG7pIe iUPhwWfJwmUyrMmm6bwfVzcVbOEDv51d6zSLg/Fcip4vpmro70Xc/amoJ2u+WM+C15WB FfKjZ+T+c87ncjfKZDOlxgGYbt0dPDbwYFYK6i1iEnnJDCwPzSEinSyMyl0++7tkHjLL ufig== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-28321-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28321-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id x17-20020a0cb211000000b006804878839bsi10843869qvd.358.2024.01.16.14.33.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 14:33:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-28321-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-28321-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28321-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 2462F1C28368 for ; Tue, 16 Jan 2024 22:33:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EBA19208C0; Tue, 16 Jan 2024 21:54:03 +0000 (UTC) Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25ABA1D6BD; Tue, 16 Jan 2024 21:54:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705442043; cv=none; b=s5OWPmiug9h4/vNIJtm/X+vRGzJMHf/OZnE4bzDIh76uBpPYupGHdgDHdw3j/JVB4/zseQgZEJ2bjyS/FIkzJ3LZMtH2hRZ0THHt1O9m1g/H6xWB5oGUhmcePIn3e+GUtnMK6/agVIz/SgUyBnGzGplS7dVspsPHbaqFOXC9VgA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705442043; c=relaxed/simple; bh=etsIip4ervQ72CbIa+MN2P8hU3lpHAA1QXD3Z7KizAY=; h=Received:X-Google-DKIM-Signature:X-Gm-Message-State: X-Google-Smtp-Source:X-Received:MIME-Version:References: In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Content-Type: Content-Transfer-Encoding; b=aClxlfNpxeZ5d8BVVvMxGtECevkFuGAkbirb8EWRAKufumkVFLbFierq2g8KpqzNFbfr/UcoWyjc1qdqQASovdBf2bUxk3lFP3Rria4PiQdWv9Q4l6Epx4KPB4Ffvz4T7xQwWo9FHSYR2YegDHNasYOGAgFkTNlVs6lEvx7DQBE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.215.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-5cddfe0cb64so4552897a12.0; Tue, 16 Jan 2024 13:54:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705442040; x=1706046840; h=content-transfer-encoding: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=P00sqh0pFFh48+YMUrZPqOjo0LVvWK+WBACLbeRVv8E=; b=p10/bRIwETHbY+NFeTu5/inmdAaf7s6koXAQ/v0Y2YYV4SG8VG6PZ6LppWB6w5ddKY WX6+YfbzcJmwnyBNtYGpLSjVo44ke4ghrVQKDZZ9lB4RrAfPw2lI7ynpynVXbcAD3ZjM zQSeg4dMBPccHbqwHI/6OEzMcevwll82AWcVpl4QTtmjvULXqMIy3SV3ei5fKZL2ivW+ YoxqDMz6EMpMHHr7quFsNwetNW5lyQFB4ZVrabN7ogIzC6I0oe6n+pnj9oVoI4CpL0eC uC47PlhH69racAWGFj8ogs+HEUM/7jTsfjHolFQaklaqSeVfYEdWvvAdTMOt3w/K+mux K1RQ== X-Gm-Message-State: AOJu0Yxf1lkuoAZZ8IfW9/bfuBmiAbzVqJXziFBNQI4/aC6g8j8nq68P onprHJQpmv7J6vgxnG8DYRMUxN8gUZqkMG0taog= X-Received: by 2002:a05:6a20:8418:b0:199:aeaf:cd3b with SMTP id c24-20020a056a20841800b00199aeafcd3bmr4230377pzd.42.1705442040272; Tue, 16 Jan 2024 13:54:00 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240111232923.8138-1-ilkka@os.amperecomputing.com> <2c9f5893-450c-012b-b748-a8fe8ddfae86@arm.com> In-Reply-To: <2c9f5893-450c-012b-b748-a8fe8ddfae86@arm.com> From: Namhyung Kim Date: Tue, 16 Jan 2024 13:53:49 -0800 Message-ID: Subject: Re: [PATCH] perf data convert: Fix segfault when converting to json on arm64 To: Ilkka Koskinen Cc: James Clark , 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 , Ian Rogers , Adrian Hunter Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello, On Fri, Jan 12, 2024 at 3:35=E2=80=AFAM James Clark w= rote: > > > > On 11/01/2024 23:29, Ilkka Koskinen wrote: > > Arm64 doesn't have Model in /proc/cpuinfo and, thus, cpu_desc doesn't g= et > > 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. Makes sense. Ilkka, can you send v2 with this? Thanks, Namhyung