From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 74949 invoked by alias); 11 May 2015 10:55:08 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 74940 invoked by uid 89); 11 May 2015 10:55:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 11 May 2015 10:55:06 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t4BAt1gO026762 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 11 May 2015 06:55:02 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4BAt0PH008846; Mon, 11 May 2015 06:55:00 -0400 Message-ID: <55508A83.3060605@redhat.com> Date: Mon, 11 May 2015 10:55:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Joel Brobecker , gdb-patches@sourceware.org Subject: Re: [RFA/commit] Memory leak in on reading frame register References: <1431100524-7793-1-git-send-email-brobecker@adacore.com> In-Reply-To: <1431100524-7793-1-git-send-email-brobecker@adacore.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-05/txt/msg00246.txt.bz2 On 05/08/2015 04:55 PM, Joel Brobecker wrote: > [On behalf of Jerome Guitton] > > When using a conditional breakpoint where the condition evaluated > to false a large number of times before the program stopped, > a user reported that GDB's memory consumption was growing very > quickly until it ran out of memory. > > The problem was tracked down to temporary struct values being created > each time the program stops and we evaluate those conditions. This > patch fixes the issue by releasing the temporary values, and adds > a comment explaining why we do that. > > gdb/ChangeLog: > > Jerome Guitton : > * findvar.c (read_frame_register_value): Fix a memory leak. > > Tested on x86_64-linux. No regression. > Not sure about this. How come this in bpstat_check_breakpoint_conditions didn't handle this issue already? : ... /* We use value_mark and value_free_to_mark because it could be a long time before we return to the command level and call free_all_values. We can't call free_all_values because we might be in the middle of evaluating a function call. */ struct value *mark = value_mark (); ... value_free_to_mark (mark); ... Otherwise, what is releasing other kinds of temporary values? Are we leaking them? E.g., with: int global_val; void foo () {} int main () { while (1) foo (); } and then: (gdb) break foo if global_var == 1 an/or: (gdb) break foo if (global_var + 1) == 2 Maybe nothing breaks with this patch as its deleting register lval values, but the case above would involve lval_memory values, and if we did something for those like in this patch, I fear that places that want to walk an expression's value chain, like update_watchpoint / can_use_hardware_watchpoint would break. Thanks, Pedro Alves