summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-12-12 19:26:06 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-12-12 19:26:06 (GMT)
commit2795e6c1c44c5572191de711cd2526dd1ec2f072 (patch)
tree39f08993912e94813ec392df30b610b67d7c9fd0
parenta6cdd83f7f0dec657d2ee3513ab63c103aacf6f4 (diff)
downloadcpython-2795e6c1c44c5572191de711cd2526dd1ec2f072.zip
cpython-2795e6c1c44c5572191de711cd2526dd1ec2f072.tar.gz
cpython-2795e6c1c44c5572191de711cd2526dd1ec2f072.tar.bz2
Merged revisions 76764 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r76764 | antoine.pitrou | 2009-12-12 20:18:27 +0100 (sam., 12 déc. 2009) | 12 lines Merged revisions 76763 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r76763 | antoine.pitrou | 2009-12-12 20:13:08 +0100 (sam., 12 déc. 2009) | 7 lines Issue #7466: segmentation fault when the garbage collector is called in the middle of populating a tuple. Patch by Florent Xicluna. (note: no NEWS entry for trunk since the bug was introduced in 2.7/3.1) ........ ................
-rw-r--r--Lib/test/test_tuple.py3
-rw-r--r--Misc/NEWS3
-rw-r--r--Objects/tupleobject.c3
3 files changed, 8 insertions, 1 deletions
diff --git a/Lib/test/test_tuple.py b/Lib/test/test_tuple.py
index c37adc2..53065bb 100644
--- a/Lib/test/test_tuple.py
+++ b/Lib/test/test_tuple.py
@@ -146,6 +146,9 @@ class TupleTest(seq_tests.CommonTest):
pass
self.check_track_dynamic(MyTuple, True)
+ def test_bug7466(self):
+ # Trying to untrack an unfinished tuple could crash Python
+ self._not_tracked(tuple(gc.collect() for i in range(101)))
def test_main():
support.run_unittest(TupleTest)
diff --git a/Misc/NEWS b/Misc/NEWS
index d965a11..237558d 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 3.1.2?
Core and Builtins
-----------------
+- Issue #7466: segmentation fault when the garbage collector is called
+ in the middle of populating a tuple. Patch by Florent Xicluna.
+
- Issue #7419: setlocale() could crash the interpreter on Windows when called
with invalid values.
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index 290107a..884174d 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -850,7 +850,8 @@ _PyTuple_Resize(PyObject **pv, Py_ssize_t newsize)
/* XXX UNREF/NEWREF interface should be more symmetrical */
_Py_DEC_REFTOTAL;
- _PyObject_GC_UNTRACK(v);
+ if (_PyObject_GC_IS_TRACKED(v))
+ _PyObject_GC_UNTRACK(v);
_Py_ForgetReference((PyObject *) v);
/* DECREF items deleted by shrinkage */
for (i = newsize; i < oldsize; i++) {