summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-10-27 12:56:06 +0000
committerAntoine Pitrou <solipsis@pitrou.net>2009-10-27 12:56:06 +0000
commit686c9adbd574cdd847f8c64556021aa3a502b5c7 (patch)
treec26794656f03aeaa4688537b95e1b08b1ed56edc
parent9aece75269872fa5cb942fb5ba642531de2d09fe (diff)
downloadcpython-git-686c9adbd574cdd847f8c64556021aa3a502b5c7.tar.gz
Merged revisions 75367 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r75367 | antoine.pitrou | 2009-10-11 23:03:26 +0200 (dim., 11 oct. 2009) | 4 lines Issue #7084: Fix a (very unlikely) crash when printing a list from one thread, and mutating it from another one. Patch by Scott Dial. ........
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS3
-rw-r--r--Objects/listobject.c7
3 files changed, 10 insertions, 1 deletions
diff --git a/Misc/ACKS b/Misc/ACKS
index f6433f707d..dbe495b084 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -167,6 +167,7 @@ Arnaud Delobelle
Erik Demaine
Roger Dev
Raghuram Devarakonda
+Scott Dial
Toby Dickenson
Mark Dickinson
Daniel Diniz
diff --git a/Misc/NEWS b/Misc/NEWS
index 135d0a2310..aaac9ef0d7 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -16,6 +16,9 @@ Core and Builtins
fixes the problem of some exceptions being thrown at shutdown when the
interpreter is killed. Patch by Adam Olsen.
+- Issue #7084: Fix a (very unlikely) crash when printing a list from one
+ thread, and mutating it from another one. Patch by Scott Dial.
+
Library
-------
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 98d7e47354..c5b1475802 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -319,6 +319,7 @@ list_print(PyListObject *op, FILE *fp, int flags)
{
int rc;
Py_ssize_t i;
+ PyObject *item;
rc = Py_ReprEnter((PyObject*)op);
if (rc != 0) {
@@ -333,15 +334,19 @@ list_print(PyListObject *op, FILE *fp, int flags)
fprintf(fp, "[");
Py_END_ALLOW_THREADS
for (i = 0; i < Py_SIZE(op); i++) {
+ item = op->ob_item[i];
+ Py_INCREF(item);
if (i > 0) {
Py_BEGIN_ALLOW_THREADS
fprintf(fp, ", ");
Py_END_ALLOW_THREADS
}
- if (PyObject_Print(op->ob_item[i], fp, 0) != 0) {
+ if (PyObject_Print(item, fp, 0) != 0) {
+ Py_DECREF(item);
Py_ReprLeave((PyObject *)op);
return -1;
}
+ Py_DECREF(item);
}
Py_BEGIN_ALLOW_THREADS
fprintf(fp, "]");