Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: paul cannon <paul@thepaul.org>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH][PR python/21460] Avoid segfault during Python cleanup
Date: Sun, 11 Jun 2017 20:59:00 -0000	[thread overview]
Message-ID: <69e1e2d6b7054702d39a081238590633@polymtl.ca> (raw)
In-Reply-To: <20170525162612.GA10119@turing>

Hi Paul,

On 2017-05-25 18:26, paul cannon wrote:
> Rationale for the patch and repro instructions are explained in the 
> bug.

Thanks for the patch, and sorry for the little delay in processing it.  
I think the code in itself is good.  I'll just point out a few things to 
fix.

> I don't have any copyright assignment on file but this really should
> be trivial enough to avoid that, I think.

That's what I think too.  Do you intend to contribute to GDB regularly?  
If so we can get you write access to the repo.  If not, I can push the 
patch on your behalf (when the issues I mentioned are fixed).

> gdb/Changelog:
> 2017-05-25  paul cannon  <paul@thepaul.org>

Should your name have capital letters :) ?

> 
> 	python/21460
> 	* python.c (gdbpy_set_quit_flag) Check Py_IsInitialized() before
> calling PyErr_SetInterrupt(), as Python may be shutting down already.

The ChangeLog should only contain "what" changed and not "why".  So just 
the first part:

   Check Py_IsInitialized() before calling PyErr_SetInterrupt().

is sufficient.  However, the why should be contained in the commit 
message.  You did a good job at explaining the problem in the bug you 
filed, so I think you could just take that and put it in the commit log 
(and massage it a bit if needed).

> 
> ---
>  gdb/python/python.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/gdb/python/python.c b/gdb/python/python.c
> index be92f36..c6a8c17 100644
> --- a/gdb/python/python.c
> +++ b/gdb/python/python.c
> @@ -247,7 +247,10 @@ gdbpy_enter::~gdbpy_enter ()
>  static void
>  gdbpy_set_quit_flag (const struct extension_language_defn *extlang)
>  {
> -  PyErr_SetInterrupt ();
> +  if (Py_IsInitialized ())
> +    {
> +      PyErr_SetInterrupt ();
> +    }

Drop the braces for a single line body:

   if (Py_IsInitialized ())
     PyErr_SetInterrupt ();

>  }
>  
>  /* Return true if the quit flag has been set, false otherwise.  */
> -- 
> 2.7.4

Thanks!

Simon


  reply	other threads:[~2017-06-11 20:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-25 16:26 paul cannon
2017-06-11 20:59 ` Simon Marchi [this message]
2017-06-15 20:30   ` Sergio Durigan Junior

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=69e1e2d6b7054702d39a081238590633@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=paul@thepaul.org \
    /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