From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 122834 invoked by alias); 3 Aug 2016 15:14:18 -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 122175 invoked by uid 89); 3 Aug 2016 15:14:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.2 spammy=11017, 2016-08-03 X-HELO: gproxy5-pub.mail.unifiedlayer.com Received: from gproxy5-pub.mail.unifiedlayer.com (HELO gproxy5-pub.mail.unifiedlayer.com) (67.222.38.55) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Wed, 03 Aug 2016 15:14:07 +0000 Received: (qmail 6209 invoked by uid 0); 3 Aug 2016 15:14:05 -0000 Received: from unknown (HELO CMOut01) (10.0.90.82) by gproxy5.mail.unifiedlayer.com with SMTP; 3 Aug 2016 15:14:05 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id SfDy1t00a2f2jeq01fE1ix; Wed, 03 Aug 2016 09:14:03 -0600 X-Authority-Analysis: v=2.1 cv=AL9Ak13q c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=PnD2wP_eR3oA:10 a=Fb7EGeu-kQ4A:10 a=7z1cN_iqozsA:10 a=pGLkceISAAAA:8 a=zstS-IiYAAAA:8 a=AemX7-9AUDrQb4hTJxwA:9 a=6kGIvZw6iX1k4Y-7sg4_:22 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from [65.128.92.157] (port=59572 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1bUxrr-0001Ny-95; Wed, 03 Aug 2016 09:13:59 -0600 From: Tom Tromey To: Yao Qi Cc: Pedro Alves , Tom Tromey , "gdb-patches\@sourceware.org" Subject: Re: [RFA] PR python/18565 - make Frame.function work for inline frames References: <1466439050-11330-1-git-send-email-tom@tromey.com> <86ziqfq6sz.fsf@gmail.com> <8737o5kqtv.fsf@tromey.com> <87bn1lu5h9.fsf@tromey.com> <5ab877f8-9e39-6e02-2ece-46fcbcdacc0a@redhat.com> Date: Wed, 03 Aug 2016 15:14:00 -0000 In-Reply-To: (Yao Qi's message of "Wed, 3 Aug 2016 09:15:48 +0100") Message-ID: <87eg65lwb2.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.95 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Identified-User: {36111:box522.bluehost.com:elynrobi:tromey.com} {sentby:smtp auth 65.128.92.157 authed with tom+tromey.com} X-Exim-ID: 1bUxrr-0001Ny-95 X-Source-Sender: (bapiya) [65.128.92.157]:59572 X-Source-Auth: tom+tromey.com X-Email-Count: 0 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-SW-Source: 2016-08/txt/msg00062.txt.bz2 >>>>> "Yao" == Yao Qi writes: >> In any case, IMO this would be the subject of a separate patch. Yao> This is the prerequisite of Tom's patch, no? It guarantees that *FUNNAME Yao> is not allocated if exception is thrown, otherwise *FUNAME is allocated. Yao> Tom's patch relies on this behaviour. Yao> I am OK with Tom's original patch, but we need to fix find_frame_funname Yao> first. Here's a patch. Please review. I'd like to check this and the other into the 7.12 branch as well. Tom commit d10153cfc6cb319a75ceb3e3d34ac30efa17e518 Author: Tom Tromey Date: Wed Aug 3 08:27:56 2016 -0600 Avoid potential memory leak in find_frame_funname The PR 18565 thread pointed out that, if cp_remove_params can throw (we aren't quite sure), then find_frame_funname could leak some memory. This patch avoids any potential issue by rearranging some code in find_frame_funname. Built and regtested on x86-64 Fedora 24. 2016-08-03 Tom Tromey * stack.c (find_frame_funname): Avoid any possible leak in case cp_remove_params can throw. diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6b2fb9c..48ecd67 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2016-08-03 Tom Tromey + * stack.c (find_frame_funname): Avoid any possible leak in case + cp_remove_params can throw. + +2016-08-03 Tom Tromey + * NEWS: Mention new Python breakpoint events. 2016-08-02 Tom Tromey diff --git a/gdb/stack.c b/gdb/stack.c index b9e74df..e890949 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1101,7 +1101,8 @@ find_frame_funname (struct frame_info *frame, char **funname, } else { - *funname = xstrdup (SYMBOL_PRINT_NAME (func)); + const char *print_name = SYMBOL_PRINT_NAME (func); + *funlang = SYMBOL_LANGUAGE (func); if (funcp) *funcp = func; @@ -1112,14 +1113,17 @@ find_frame_funname (struct frame_info *frame, char **funname, stored in the symbol table, but we stored a version with DMGL_PARAMS turned on, and here we don't want to display parameters. So remove the parameters. */ - char *func_only = cp_remove_params (*funname); + char *func_only = cp_remove_params (print_name); if (func_only) - { - xfree (*funname); - *funname = func_only; - } + *funname = func_only; } + + /* If we didn't hit the C++ case above, set *funname here. + This approach is taken to avoid having to install a + cleanup in case cp_remove_params can throw. */ + if (*funname == NULL) + *funname = xstrdup (print_name); } } else