From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756111AbdJRLvA (ORCPT ); Wed, 18 Oct 2017 07:51:00 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:60860 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755522AbdJRLu5 (ORCPT ); Wed, 18 Oct 2017 07:50:57 -0400 From: Ravi Bangoria To: acme@kernel.org, ak@linux.intel.com Cc: alexander.shishkin@linux.intel.com, peterz@infradead.org, mingo@redhat.com, jolsa@kernel.org, linux-kernel@vger.kernel.org, Ravi Bangoria Subject: [PATCH] perf record: Fix tool crash with xyarray Date: Wed, 18 Oct 2017 17:20:46 +0530 X-Mailer: git-send-email 2.7.4 X-TM-AS-MML: disable x-cbid: 17101811-0016-0000-0000-000004F6FE89 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17101811-0017-0000-0000-0000283252DD Message-Id: <1508327446-15302-1-git-send-email-ravi.bangoria@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-10-18_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710180167 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I see 'perf record -p ' crashes with following log: *** Error in `./perf': free(): invalid next size (normal): 0x000000000298b340 *** ======= Backtrace: ========= /lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f7fd85c87e5] /lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7f7fd85d137a] /lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f7fd85d553c] ./perf(perf_evsel__close+0xb4)[0x4b7614] ./perf(perf_evlist__delete+0x100)[0x4ab180] ./perf(cmd_record+0x1d9)[0x43a5a9] ./perf[0x49aa2f] ./perf(main+0x631)[0x427841] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f7fd8571830] ./perf(_start+0x29)[0x427a59] This is because functions xyarray__max_x() and xyarray__max_y() are returning incorrect values, causing crash while accessing xyarray. Fixes: d74be4767367 ("perf xyarray: Save max_x, max_y") Signed-off-by: Ravi Bangoria --- tools/perf/util/xyarray.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/xyarray.h b/tools/perf/util/xyarray.h index 4ba726c..d6858ed 100644 --- a/tools/perf/util/xyarray.h +++ b/tools/perf/util/xyarray.h @@ -21,12 +21,12 @@ static inline void *xyarray__entry(struct xyarray *xy, int x, int y) return &xy->contents[x * xy->row_size + y * xy->entry_size]; } -static inline int xyarray__max_y(struct xyarray *xy) +static inline int xyarray__max_x(struct xyarray *xy) { return xy->max_x; } -static inline int xyarray__max_x(struct xyarray *xy) +static inline int xyarray__max_y(struct xyarray *xy) { return xy->max_y; } -- 2.7.4