From: Tom Tromey <tom@tromey.com>
To: Yao Qi <qiyaoltc@gmail.com>
Cc: Pedro Alves <palves@redhat.com>, Tom Tromey <tom@tromey.com>,
"gdb-patches\@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [RFA] PR python/18565 - make Frame.function work for inline frames
Date: Wed, 03 Aug 2016 15:14:00 -0000 [thread overview]
Message-ID: <87eg65lwb2.fsf@tromey.com> (raw)
In-Reply-To: <CAH=s-PNWibRbzTeNfROd9fR=Y-Pn7zkFDwZpPAnyuW9rDKCmGw@mail.gmail.com> (Yao Qi's message of "Wed, 3 Aug 2016 09:15:48 +0100")
>>>>> "Yao" == Yao Qi <qiyaoltc@gmail.com> 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 <tom@tromey.com>
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 <tom@tromey.com>
* 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 <tom@tromey.com>
+ * stack.c (find_frame_funname): Avoid any possible leak in case
+ cp_remove_params can throw.
+
+2016-08-03 Tom Tromey <tom@tromey.com>
+
* NEWS: Mention new Python breakpoint events.
2016-08-02 Tom Tromey <tom@tromey.com>
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
next prev parent reply other threads:[~2016-08-03 15:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-20 16:11 Tom Tromey
[not found] ` <86ziqfq6sz.fsf@gmail.com>
2016-06-22 18:43 ` Tom Tromey
2016-07-25 10:23 ` Yao Qi
2016-07-25 11:04 ` Pedro Alves
2016-07-25 15:01 ` Tom Tromey
2016-07-26 11:14 ` Pedro Alves
2016-07-26 13:18 ` Tom Tromey
2016-07-26 14:33 ` Pedro Alves
2016-08-03 8:15 ` Yao Qi
2016-08-03 15:14 ` Tom Tromey [this message]
2016-08-03 17:57 ` Pedro Alves
2016-08-03 8:07 ` Yao Qi
2016-08-03 11:35 ` Pedro Alves
2016-08-03 13:15 ` Yao Qi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87eg65lwb2.fsf@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=qiyaoltc@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox