From: paul cannon <paul@thepaul.org>
To: gdb-patches@sourceware.org
Subject: [PATCH][PR python/21460] Avoid segfault during Python cleanup
Date: Thu, 25 May 2017 16:26:00 -0000 [thread overview]
Message-ID: <20170525162612.GA10119@turing> (raw)
Rationale for the patch and repro instructions are explained in the bug.
I don't have any copyright assignment on file but this really should be trivial enough to avoid that, I think.
gdb/Changelog:
2017-05-25  paul cannon  <paul@thepaul.org>
python/21460
* python.c (gdbpy_set_quit_flag) Check Py_IsInitialized() before calling PyErr_SetInterrupt(), as Python may be shutting down already.
---
 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 ();
+ Â Â }
 }
Â
 /* Return true if the quit flag has been set, false otherwise.  */
--Â
2.7.4
next reply other threads:[~2017-05-25 16:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-25 16:26 paul cannon [this message]
2017-06-11 20:59 ` Simon Marchi
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=20170525162612.GA10119@turing \
--to=paul@thepaul.org \
--cc=gdb-patches@sourceware.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