summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2018-05-28 11:11:31 -0400
committerGitHub <noreply@github.com>2018-05-28 11:11:31 -0400
commit35230d08e09de4e2e52658d5cb09e5b0ca965418 (patch)
tree73cbdf7abc99d5b8b3ec09f158f96dcd78e81914 /Modules
parent08c5aca9d13b24b35faf89ebd26fc348ae1731b2 (diff)
downloadcpython-git-35230d08e09de4e2e52658d5cb09e5b0ca965418.tar.gz
bpo-33623: Fix possible SIGSGV when asyncio.Future is created in __del__ (#7080)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_asynciomodule.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c
index 6d7249a580..c4d19034ce 100644
--- a/Modules/_asynciomodule.c
+++ b/Modules/_asynciomodule.c
@@ -501,7 +501,13 @@ future_init(FutureObj *fut, PyObject *loop)
if (is_true < 0) {
return -1;
}
- if (is_true) {
+ if (is_true && !_Py_IsFinalizing()) {
+ /* Only try to capture the traceback if the interpreter is not being
+ finalized. The original motivation to add a `_Py_IsFinalizing()`
+ call was to prevent SIGSEGV when a Future is created in a __del__
+ method, which is called during the interpreter shutdown and the
+ traceback module is already unloaded.
+ */
fut->fut_source_tb = _PyObject_CallNoArg(traceback_extract_stack);
if (fut->fut_source_tb == NULL) {
return -1;