Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1297363imu; Wed, 16 Jan 2019 16:39:36 -0800 (PST) X-Google-Smtp-Source: ALg8bN5wGOR8IRSJL6WQeO+h+rmwNmtV5Sox5AvCyB542ZYl4SrnlRVI3jBU0w6lGLgSXJvj3JJV X-Received: by 2002:a63:902:: with SMTP id 2mr10821349pgj.219.1547685576507; Wed, 16 Jan 2019 16:39:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547685576; cv=none; d=google.com; s=arc-20160816; b=eJRr/T64egiL1Gif9PTRPCjM7cpmiXzqBV5mzphx7QziOCP+zL834InJ2hZmOQJuTb jWK7Cst+wpiHS7WIHl3kM1QvcE5WAyCw80NNTEzV/2SFD0/GnCztKx+oAVGy6WXh4Sro nz5A34JgFmWF1RRZFXHofMl4iWq8yT93dqeFEX6unSzl9dbGN7Hix99evOKvYPcs7c4r r946/qVRHulV4BtsK2T7Hcg4mmtYN+KkcgBPZp/evv/28XVgabzdSnBRrd6Pkicb+NQj MWzrzLzb+UH6j3HxcwmyhGlvVzE3h7KMU2C4yIy7qt3x+w/0+FCWRM992ljrgMfTA63H xVug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=1nmgVachyw0GrBcWuTmAZOikNQlMkmOmUJ43VJKDShQ=; b=cVLBhRVxj11dYgupx/l2Qxdim2ny9D1vfFc9xpWPIwrLnC7ZrbWc4tQh0P4doZ3f+K r2GcMNVX64G6+9T0AjeqnFYhydTw6GhOU1EY4Rlt3y6+QZWbmqfPgSOt9tBjY/OWAqDm 7LukYOolC36gfzQlIKsbrqe4AxLKg5GrOn7YCVoxuZpZ9h8/DSDayhdI3/62RT/9iF6p a+fqihEx9k3WrqKviA9uMbENPGk6ya5WAbbl7iQMj8Cz+CashbnJNM+DyK4nSzbzU7aA 1/2rgjVt6UPQhu+6HZXREfr+dlXtq/eJZ4VSqvHyZD/chGPOhzNmw2BMxwAXWS8qtLHy 01GA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5si7055781pga.440.2019.01.16.16.39.20; Wed, 16 Jan 2019 16:39:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730464AbfAPVe2 (ORCPT + 99 others); Wed, 16 Jan 2019 16:34:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37340 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729732AbfAPVe1 (ORCPT ); Wed, 16 Jan 2019 16:34:27 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 93EDA369C9; Wed, 16 Jan 2019 21:34:27 +0000 (UTC) Received: from krava (ovpn-204-68.brq.redhat.com [10.40.204.68]) by smtp.corp.redhat.com (Postfix) with SMTP id 5198B5D9CA; Wed, 16 Jan 2019 21:34:26 +0000 (UTC) Date: Wed, 16 Jan 2019 22:34:25 +0100 From: Jiri Olsa To: Song Liu Cc: open list , Jiri Olsa , acme@kernel.org Subject: Re: perf segfault in in ordered_events__free() Message-ID: <20190116213425.GA16366@krava> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 16 Jan 2019 21:34:27 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 16, 2019 at 10:57:49AM -0800, Song Liu wrote: > Hi, > > We are debugging a segfault of perf in ordered_events__free(). hi, any backtrace or info on how to reproduce it? > Disassemble shows the segfault was caused by oe->buff == NULL > in the following line: > > /* > * Current buffer might not have all the events allocated > * yet, we need to free only allocated ones ... > */ > list_del(&oe->buffer->list); > > After poking around the code, I suspect it is caused by the following > condition in alloc_event(): > > } else if (oe->buffer) { > new = &oe->buffer->event[oe->buffer_idx]; > if (++oe->buffer_idx == MAX_SAMPLE_BUFFER) > oe->buffer = NULL; argh.. yea, we need to check oe->buffer in ordered_events__free would attached change fix it for you? thanks, jirka --- diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-events.c index 897589507d97..ea523d3b248f 100644 --- a/tools/perf/util/ordered-events.c +++ b/tools/perf/util/ordered-events.c @@ -391,8 +391,10 @@ void ordered_events__free(struct ordered_events *oe) * Current buffer might not have all the events allocated * yet, we need to free only allocated ones ... */ - list_del(&oe->buffer->list); - ordered_events_buffer__free(oe->buffer, oe->buffer_idx, oe); + if (oe->buffer) { + list_del(&oe->buffer->list); + ordered_events_buffer__free(oe->buffer, oe->buffer_idx, oe); + } /* ... and continue with the rest */ list_for_each_entry_safe(buffer, tmp, &oe->to_free, list) {