This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author denny
Recipients denny, r.david.murray
Date 2010-08-09.05:16:19
SpamBayes Score 6.246989e-05
Marked as misclassified No
Message-id <1281330983.3.0.486559668665.issue9532@psf.upfronthosting.co.za>
In-reply-to
Content
Hi David

I have tried in another testbd with python 2.6.5, and the problem of hang doesn't reproduce, after retrying for several times.

The original hang happens in pipe.read of commands module.

After comparing the code of python 2.4.4 and python 2.6.5, I noticed two enhancements in posimodule.c:posix_read.

These defensive coding add precheck, before invoking read function.

David, without these enhancements, would it cause the potential hang problem, in your opinion?
Recompiling python 2.4.4 with some manual changes is a little scaring to me.

,----------- python 2.4.4 posixmodule.c
| static PyObject *
| posix_read(PyObject *self, PyObject *args)
| {
|     int fd, size, n;
|     PyObject *buffer;
|     if (!PyArg_ParseTuple(args, "ii:read", &fd, &size))
|         return NULL;
|     buffer = PyString_FromStringAndSize((char *)NULL, size);
|     if (buffer == NULL)
|         return NULL;
|     Py_BEGIN_ALLOW_THREADS
|     n = read(fd, PyString_AsString(buffer), size);
|     Py_END_ALLOW_THREADS
|     if (n < 0) {
|         Py_DECREF(buffer);
|         return posix_error();
|     }
|     if (n != size)
|         _PyString_Resize(&buffer, n);
|     return buffer;
| }
`-----------

,----------- 2.6.5 posixmodule.c
| static PyObject *
| posix_read(PyObject *self, PyObject *args)
| {
|     int fd, size, n;
|     PyObject *buffer;
|     if (!PyArg_ParseTuple(args, "ii:read", &fd, &size))
|         return NULL;
|     if (size < 0) {
|         errno = EINVAL;
|         return posix_error();
|     }
|     buffer = PyString_FromStringAndSize((char *)NULL, size);
|     if (buffer == NULL)
|         return NULL;
|     if (!_PyVerify_fd(fd))
|         return posix_error();
|     Py_BEGIN_ALLOW_THREADS
|     n = read(fd, PyString_AsString(buffer), size);
|     Py_END_ALLOW_THREADS
|     if (n < 0) {
|         Py_DECREF(buffer);
|         return posix_error();
|     }
|     if (n != size)
|         _PyString_Resize(&buffer, n);
|     return buffer;
| }
`-----------
History
Date User Action Args
2010-08-09 05:16:23dennysetrecipients: + denny, r.david.murray
2010-08-09 05:16:23dennysetmessageid: <1281330983.3.0.486559668665.issue9532@psf.upfronthosting.co.za>
2010-08-09 05:16:21dennylinkissue9532 messages
2010-08-09 05:16:20dennycreate