Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp766082lqo; Fri, 10 May 2024 14:28:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV8fm1AoaUd6M036wQ84cW3eLg7pARUHKSZQSAP8n5Z0RVyVZbmh8MmOkkhNFcE8mo/+dbncMBZew6BYDdOi8Qxbmfv4ywhniYjaMCpfA== X-Google-Smtp-Source: AGHT+IEEquzj80qch6hCm4loqK077kvWY4ZtJ0Xx5Qc+2WxUgfM02EtwQsh2zbshhplY7/+kMhFv X-Received: by 2002:a05:620a:c99:b0:790:b6a4:6762 with SMTP id af79cd13be357-792c75f3641mr359121185a.53.1715376486453; Fri, 10 May 2024 14:28:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715376486; cv=pass; d=google.com; s=arc-20160816; b=fhXZajab2m2z8F6jlvMt4Rzs8K1N5uE1B4BnEVoLfgE9+didtlpbXyBkpK/tPT+F+P mFGtK7NwwAOPM5M1lb6r8N4qBwru1xW52BinqpBJhYGdNwVy63SQoysFDmssedYhnAiW sGusSh1ZCLqRFly0tibNe5iO0STJHtMu6aYBm/yRQQFy5zGTHPKk0opdlAxs+7Lb/CdD rMvQYDoltV/RwCnI9aIQAyR6d3z1Ddr+NU5ypPT7m3tNkXoSq82FU0DWEHfrJ1vW9ze8 xGIY1YptnjRHw9BqlRQiJfsHZoQtR0L3DZT8UjTOXn5vAAY2oVLEEsrKWQIDTXsMsxZh QTBQ== 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:dkim-signature; bh=5mKJDhvKiTqgTK80eZzW3APk5Ua5WfNa0sYKeeiCXcs=; fh=FUYT0Bwv/pE/xiM6/+CARi4oyoHiYSUBUud4bZlImrc=; b=SDkqr12J7u+T5hEk6tFUnQrwb9IXSFbJj6Id3r5Rypx09IT6JNY5Y3cocvE04GqLY8 cXhStIAVgjHrLddtkIN5r2Zjly1wzatim5wwdWyY5tqj5+jO/7vnovZG1jegrzGid9Ow ohh/MC4qIPgpTuwW5zb5gOQylvGgZE0JGLmKXzOXcOZ/MZDHFx7hbH69viOOHnK50epv gdhCFKl8BBrHSYfYnqFOeYFD+wRkVFx8tzZWln7y2s9zu51C4/MSkhqSJd/iDpuujv+y tTz22P1sb6vCnM8SH8NUmfYp4CXWGORqBZOdzcF7pUm7qSVr6fzmKoqH0RSsOmlAjGrn 1J/Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=TNvAbBlx; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-176236-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176236-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-792bf2777e8si424040985a.105.2024.05.10.14.28.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 14:28:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-176236-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=TNvAbBlx; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-176236-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176236-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 981D21C2261F for ; Fri, 10 May 2024 21:27:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9535513B78E; Fri, 10 May 2024 21:27:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="TNvAbBlx" Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) (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 E8E8013B5A4 for ; Fri, 10 May 2024 21:27:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715376471; cv=none; b=sVkc1tgkPvX++aqL7pxnUdz/f/dDXtmdM81VE/EbLnSrJ4g2vvLQFqvipIUu5uKA6illl1j6rUOh4AyvAN/HfLyQvzycz0JwsBX47YRyC7dWd51cp70Cq3ZtuYaGFMadEvmySOE+ZxF6FZ8EgcyjQC1i/Eqk/2/6BZiW5Lp//Ms= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715376471; c=relaxed/simple; bh=hb8r21bsZDeQ6IILpMa8J4jpgSC0HQY1iW+OfrfCDS4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=qW/JekwNEsNsTNUipjZSLTNkGI1iVFC0o+zVeMRz7tfSufHF+/eVYB73YU3QGu4PDHJbdhw0IZm/M6v7jHumjXY6Lsrps4xZ6hD+7tkTTML3RzKafs+zYsY2QqAJjDCW5mSdwxtq/aUeaz4IU5/p6mwAoBwE6yk3qbN01UA5n2U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=TNvAbBlx; arc=none smtp.client-ip=209.85.160.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-43dfe020675so136911cf.0 for ; Fri, 10 May 2024 14:27:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715376468; x=1715981268; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=5mKJDhvKiTqgTK80eZzW3APk5Ua5WfNa0sYKeeiCXcs=; b=TNvAbBlxuTRKLa5wrg92RENelGxOmZ2QjrOZPDxhz3fc2lEQr1LwKnd9Ev3Ctwmike VOnXtJiOUZ0fjctYqB95Ie2lw7DPsDtvQ3/3CNpGP9e+0AcyobVGTo/y+aYciTOKHfR9 jO+Cp2AeCcWMKllpLfQl1weSDsRK8aM3lKAMDl7rxTj+LpEuOAl6rjfyFJ1YnL0IN4iH vTr7vTDl9Sq9iEWB28C8qu5ltvMlKDIS6jOCluKnq0vrzofR6ecI/IHS5Gc1AoEyAQQx ayK7f5Z2E6xINU0b6sgMfWzfReDEkYkTBia6AqkFBW8GLWXX46EJJJwf9HULiQqOSKpl m1aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715376468; x=1715981268; 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=5mKJDhvKiTqgTK80eZzW3APk5Ua5WfNa0sYKeeiCXcs=; b=bZvOYeqTSnudfOtWVG/ijk+b3CVG57ccAh3tKp5mXP//A9LUW39K2lmDE6VplANtOn /TqoOlU3c5KTeavk+UwUhuy+OtFAVcXS09aeuXeNAYv9HeCFE5aG0Q4NiK+/XGs/k6hj mMYFYurwvI3fePwb4R5aYPODgXfTfqVwbt2gAG2grPttyR44ZKMMYlXOQMbnhWMK8uDg ILAz3+zS5EbQsu5zvAD1PYBhjGbavWmHEMNYxK67e+1UA7YoT9XH9Zwxfx4OPiIBnS8W /pFbgfQmSpbRJRrCZa5MdU+3vwcqerQsMwXYFw8DFaJcY3h6xbkpSu4L5Iu7vn/q3YMC P/5w== X-Forwarded-Encrypted: i=1; AJvYcCV5daXBcKE73Dbxk7Dqxep/VkXJEUPxfGFZ+xAvWLm6V9/ncEQqIsyQeWbO02cYWoe5Cje4N/DGejgRyEn4FpSYfczNepNpM0aZ/MlR X-Gm-Message-State: AOJu0Yx4jayPXvGsGMyz54cnMQyO2GeSscDExhDjH6uoiXISIa/9qxCR 3+h4n+1XdQW0veTbmqdkzHE3w3GLx8oiSbhBdAgKf4bDGOF1fRjFwKnNqiCzxaqaBuRcWqVcWA3 njdFBAYHoB3+sZKVDS2VMeOo5RP61DtHwNNX+ X-Received: by 2002:a05:622a:4286:b0:439:ef72:75fb with SMTP id d75a77b69052e-43e0a21e3c8mr133981cf.1.1715376467681; Fri, 10 May 2024 14:27:47 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240510210452.2449944-1-namhyung@kernel.org> <20240510210452.2449944-2-namhyung@kernel.org> In-Reply-To: <20240510210452.2449944-2-namhyung@kernel.org> From: Ian Rogers Date: Fri, 10 May 2024 14:27:36 -0700 Message-ID: Subject: Re: [PATCH 2/2] perf annotate-data: Ensure the number of type histograms To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Kan Liang , Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, May 10, 2024 at 2:04=E2=80=AFPM Namhyung Kim = wrote: > > Arnaldo reported that there is a case where nr_histograms and histograms > don't agree each other. It ended up in a segfault trying to access NULL > histograms array. Let's make sure to update the nr_histograms when the > histograms array is changed. > > Reported-by: Arnaldo Carvalho de Melo > Signed-off-by: Namhyung Kim Reviewed-by: Ian Rogers Thanks, Ian > --- > tools/perf/util/annotate-data.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-d= ata.c > index 57e7d4b3550b..965da6c0b542 100644 > --- a/tools/perf/util/annotate-data.c > +++ b/tools/perf/util/annotate-data.c > @@ -1800,7 +1800,6 @@ static int alloc_data_type_histograms(struct annota= ted_data_type *adt, int nr_en > sz +=3D sizeof(struct type_hist_entry) * adt->self.size; > > /* Allocate a table of pointers for each event */ > - adt->nr_histograms =3D nr_entries; > adt->histograms =3D calloc(nr_entries, sizeof(*adt->histograms)); > if (adt->histograms =3D=3D NULL) > return -ENOMEM; > @@ -1814,6 +1813,8 @@ static int alloc_data_type_histograms(struct annota= ted_data_type *adt, int nr_en > if (adt->histograms[i] =3D=3D NULL) > goto err; > } > + > + adt->nr_histograms =3D nr_entries; > return 0; > > err: > @@ -1827,7 +1828,9 @@ static void delete_data_type_histograms(struct anno= tated_data_type *adt) > { > for (int i =3D 0; i < adt->nr_histograms; i++) > zfree(&(adt->histograms[i])); > + > zfree(&adt->histograms); > + adt->nr_histograms =3D 0; > } > > void annotated_data_type__tree_delete(struct rb_root *root) > -- > 2.45.0.118.g7fe29c98d7-goog >