From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 42439 invoked by alias); 25 May 2017 16:26:25 -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 42338 invoked by uid 89); 25 May 2017 16:26:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=shutting, HContent-Transfer-Encoding:8bit X-HELO: esther.thepaul.org Received: from thepaul.xen.prgmr.com (HELO esther.thepaul.org) (71.19.158.106) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 25 May 2017 16:26:17 +0000 Received: from aus0.edge.epochlabs.com ([38.67.3.216] helo=turing) by esther.thepaul.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1dDvad-0004RU-Av for gdb-patches@sourceware.org; Thu, 25 May 2017 11:26:19 -0500 Date: Thu, 25 May 2017 16:26:00 -0000 From: paul cannon To: gdb-patches@sourceware.org Subject: [PATCH][PR python/21460] Avoid segfault during Python cleanup Message-ID: <20170525162612.GA10119@turing> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.5.24 (2015-08-30) X-SW-Source: 2017-05/txt/msg00548.txt.bz2 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   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