Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1706809imu; Thu, 17 Jan 2019 01:49:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN680R7qtpm4emFsbTH7iR/6IbCqi9KRw+yDmpFScO6Oi15PqpBxGYJ0k5sk5X0xbrFuN101 X-Received: by 2002:a65:560e:: with SMTP id l14mr12831239pgs.168.1547718551935; Thu, 17 Jan 2019 01:49:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547718551; cv=none; d=google.com; s=arc-20160816; b=M7KEO3A+qTXYPptk9ry2swsdFJLOOx9bkBQDBoJNzrvcLEaTtRBo+kjAaIr3/vYyXY tefekSMDhNtkOXiySg1aA5i0249+pA5JDvv7Ly6EFl8jPA4hHIfmpCunSrSe5EDIWK7u GLhRjCxAXiTNsXUH7SO2wQLtRaOrH/ULUMUsoKBbyX9MEwAtl14jeO/jDB9B085YbvAJ TcBfEb3qtBMakSuMXw6CBdc9LVKbXmh0lLnZzA6aRXt96phoV2A5EsNI424+x3PhH7Bn YG+S76G8JPAd/Lj2lHKzlsSXp/ygVvXpmN0yame0gOpv93SgStiqzpEp6ANmMpaxBvyK 0ouw== 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=Ai1+MuIKubqGR6iO5V0YUpCo61N/YD5SG37F/sQJm18=; b=DaELbsk6ksZkDemmbLsuCgjRgFFQIPfJ6mzm/OnHeHBza1A6JHbnzhQKEBPDDXp+fB TDBSH228xLvmMDUhD20IhYMwRFZ3ryfdSAi1Kxt9GwzDfnDc7Z3JBQmjqrl5UOJ3vf0g A3TcwOyxmD4ai0xaAGJ7MsWJoIqxPUkuLTYtUnlCO3wQuLZ6pmHLcvSDk8sL0xBiC2rZ nnI0sIX27R++PY3Uwl3qFcVehtUB7ST4MgpNX3rcXyqyQKhzXXWK4ORTyEIwzjyAlvA5 1yFA0NM7dz6r7cKYCZyOwLmwrGNvm1emFlGqrDHdA46gpBq1W7qaDSsrUip9xjVlpJ1c PduA== 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 r11si1304515pli.175.2019.01.17.01.48.56; Thu, 17 Jan 2019 01:49:11 -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 S1728129AbfAQJS2 (ORCPT + 99 others); Thu, 17 Jan 2019 04:18:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34924 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726732AbfAQJS0 (ORCPT ); Thu, 17 Jan 2019 04:18:26 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8873AB655; Thu, 17 Jan 2019 09:18:26 +0000 (UTC) Received: from krava (ovpn-204-223.brq.redhat.com [10.40.204.223]) by smtp.corp.redhat.com (Postfix) with SMTP id D5F2860F8A; Thu, 17 Jan 2019 09:18:24 +0000 (UTC) Date: Thu, 17 Jan 2019 10:18:23 +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: <20190117091823.GB16366@krava> References: <20190116213425.GA16366@krava> 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 17 Jan 2019 09:18:26 +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 11:33:55PM -0800, Song Liu wrote: > On Wed, Jan 16, 2019 at 1:53 PM Song Liu wrote: > > > > Thanks Jiri! > > > > On Wed, Jan 16, 2019 at 1:34 PM Jiri Olsa wrote: > > > > > > 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? > > > > Here is the backtrace: > > > > #0 0x0000000000500055 in ordered_events(float, long double,...)(...) () > > #1 0x0000000000500196 in ordered_events.reinit () > > #2 0x00000000004fe413 in perf_session.process_events () > > #3 0x0000000000440431 in cmd_record () > > #4 0x00000000004a439f in run_builtin () > > #5 0x000000000042b3e5 in main ()" > > > > > > > > > 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? > > > > Let me try roll a fixed version to confirm. > > Yes, the patch fixes this segfault. Please CC me on the official patch to > back port the official version. thanks for testing, will post it today jirka