[Python-checkins] cpython (merge 3.6 -> default): Issue #28387: Fixed possible crash in _io.TextIOWrapper deallocator when
serhiy.storchaka
python-checkins at python.org
Thu Nov 3 09:39:28 EDT 2016
https://hg.python.org/cpython/rev/36af3566b67a
changeset: 104889:36af3566b67a
parent: 104885:b74897b69184
parent: 104888:c4319c0d0131
user: Serhiy Storchaka <storchaka at gmail.com>
date: Thu Nov 03 15:38:58 2016 +0200
summary:
Issue #28387: Fixed possible crash in _io.TextIOWrapper deallocator when
the garbage collector is invoked in other thread.
Based on patch by Sebastian Cufre.
files:
Misc/ACKS | 1 +
Misc/NEWS | 4 ++++
Modules/_io/textio.c | 17 +++++------------
3 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -321,6 +321,7 @@
Drew Csillag
Alessandro Cucci
Joaquin Cuenca Abela
+Sebastian Cufre
John Cugini
Tom Culliton
Raúl Cumplido
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -106,6 +106,10 @@
Library
-------
+- Issue #28387: Fixed possible crash in _io.TextIOWrapper deallocator when
+ the garbage collector is invoked in other thread. Based on patch by
+ Sebastian Cufre.
+
- Issue #27517: LZMA compressor and decompressor no longer raise exceptions if
given empty data twice. Patch by Benjamin Fogle.
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -1103,7 +1103,7 @@
}
static int
-_textiowrapper_clear(textio *self)
+textiowrapper_clear(textio *self)
{
self->ok = 0;
Py_CLEAR(self->buffer);
@@ -1116,6 +1116,8 @@
Py_CLEAR(self->snapshot);
Py_CLEAR(self->errors);
Py_CLEAR(self->raw);
+
+ Py_CLEAR(self->dict);
return 0;
}
@@ -1125,11 +1127,11 @@
self->finalizing = 1;
if (_PyIOBase_finalize((PyObject *) self) < 0)
return;
- _textiowrapper_clear(self);
+ self->ok = 0;
_PyObject_GC_UNTRACK(self);
if (self->weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *)self);
- Py_CLEAR(self->dict);
+ textiowrapper_clear(self);
Py_TYPE(self)->tp_free((PyObject *)self);
}
@@ -1151,15 +1153,6 @@
return 0;
}
-static int
-textiowrapper_clear(textio *self)
-{
- if (_textiowrapper_clear(self) < 0)
- return -1;
- Py_CLEAR(self->dict);
- return 0;
-}
-
static PyObject *
textiowrapper_closed_get(textio *self, void *context);
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list