Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp441462imp; Thu, 21 Feb 2019 04:40:11 -0800 (PST) X-Google-Smtp-Source: AHgI3IYvOKT9Ydc0FUU2tNB3WvEEGJJ0oE2KHUTQQ3Y1py5CePpmdQZuqqCTyqnHc6xymVjbiVrU X-Received: by 2002:a63:d814:: with SMTP id b20mr34805473pgh.312.1550752811323; Thu, 21 Feb 2019 04:40:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550752811; cv=none; d=google.com; s=arc-20160816; b=T/sSxl+bzHUgrn5qR7iNgGgxFuYCfvjjvyRbEaXbI4PyR23cqND7qJmIUhxHuWeodb Sliuww9eVINY4KN98hGSBMPySCF6FNUSVOUC8+l4KDMiZXey+i+u0/C3QzDhuVVBmiIn nlgHF0AX1UHa7uWnNsbvbccr4f35U4kq1nAazVTVdn3GEIH2uzw4tuGkw9M/TFFzffZP 8/ywKIdfyz6COhyKqC+rM982Su+w0RGTh7foIpawd62V1AqrMewgMaKR7ArWAOfGz/sA NEcQiayhz7Lm3yBwMlc+KOLRE3AMJItWCbVyGKh0vtxxxjHjhIJ/ZVZIOQZ+ymAsKwbt gkJg== 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=LiQanI5yMm0WZAUAy+88+flfMOW1OEJIfVEjoKXm7no=; b=anGqG3I4rrnPittpYWp6r9qfRCZayEy/1fZ5FnEIUJZJiSMubhbb/2bW99aex386v+ ovZ563irRgYJW2is1wXSZuEiFdCH+aDmlBWZII+kJd0zsJmF+v/MW0CYddpzhBBOJ62N Co5UyQOYbHtfhgxrML3rRmDfEm6OSFqEcTsCIH3GXkDngbgzHgZa4ATDoIVJQ8BubHvZ ABHPHyjpgH4ZqieDFPgh3w95fEYMkvu4sA5Lvf3K/DYIyTSwLXp90AFDitu3s7TOIyk6 JFe3yGu629dW/YuvRm9VFGxyTTW6Qyxv6Ny4KYhyiYHFQ5fVUS+ds4blynbB+/9TWnrd KZyQ== 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 h79si21205402pfa.127.2019.02.21.04.39.56; Thu, 21 Feb 2019 04:40: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 S1727573AbfBUMjM (ORCPT + 99 others); Thu, 21 Feb 2019 07:39:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57028 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725385AbfBUMjM (ORCPT ); Thu, 21 Feb 2019 07:39:12 -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 D15706696F; Thu, 21 Feb 2019 12:39:11 +0000 (UTC) Received: from krava (unknown [10.43.17.20]) by smtp.corp.redhat.com (Postfix) with SMTP id 1859A60BE6; Thu, 21 Feb 2019 12:39:09 +0000 (UTC) Date: Thu, 21 Feb 2019 13:39:09 +0100 From: Jiri Olsa To: Jonas Rabenstein Cc: linux-perf-users@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Namhyung Kim , linux-kernel@vger.kernel.org Subject: Re: [PATCH] perf hist: fix memory leak if histogram entry is reused Message-ID: <20190221123909.GG10990@krava> References: <20190221122306.1511-1-jonas.rabenstein@studium.uni-erlangen.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190221122306.1511-1-jonas.rabenstein@studium.uni-erlangen.de> 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, 21 Feb 2019 12:39:11 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 21, 2019 at 01:23:06PM +0100, Jonas Rabenstein wrote: > In __hists__add_entry the srcline of the addr_location is duplicated > for the hist_entry. If hists__findnew_entry returns an already existing > hist_entry the srcline has to be freed again as no further reference to > that duplicated srcline would exists anymore. > > Signed-off-by: Jonas Rabenstein > --- > tools/perf/util/hist.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c > index 8aad8330e392..25b8dbdbbe87 100644 > --- a/tools/perf/util/hist.c > +++ b/tools/perf/util/hist.c > @@ -623,6 +623,9 @@ __hists__add_entry(struct hists *hists, > .ops = ops, > }, *he = hists__findnew_entry(hists, &entry, al, sample_self); > > + if (he && he->srcline != entry.srcline) > + free(entry.srcline); > + > if (!hists->has_callchains && he && he->callchain_size != 0) > hists->has_callchains = true; > return he; nice, do we have similar issue in here? jirka --- diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 216388003dea..e65e6822c848 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -966,7 +966,7 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter, .map = al->map, .sym = al->sym, }, - .srcline = al->srcline ? strdup(al->srcline) : NULL, + .srcline = al->srcline, .parent = iter->parent, .raw_data = sample->raw_data, .raw_size = sample->raw_size,