Author: antoine.pitrou Date: Thu Oct 28 16:50:57 2010 New Revision: 85892 Log: Issue #9295: Fix a crash under Windows when calling close() on a file object with custom buffering from two threads at once. Modified: python/branches/release27-maint/Misc/NEWS python/branches/release27-maint/Objects/fileobject.c Modified: python/branches/release27-maint/Misc/NEWS ============================================================================== --- python/branches/release27-maint/Misc/NEWS (original) +++ python/branches/release27-maint/Misc/NEWS Thu Oct 28 16:50:57 2010 @@ -63,6 +63,9 @@ Library ------- +- Issue #9295: Fix a crash under Windows when calling close() on a file + object with custom buffering from two threads at once. + - Issue #5027: The standard ``xml`` namespace is now understood by xml.sax.saxutils.XMLGenerator as being bound to http://www.w3.org/XML/1998/namespace. Patch by Troy J. Farrell. Modified: python/branches/release27-maint/Objects/fileobject.c ============================================================================== --- python/branches/release27-maint/Objects/fileobject.c (original) +++ python/branches/release27-maint/Objects/fileobject.c Thu Oct 28 16:50:57 2010 @@ -423,6 +423,7 @@ int sts = 0; int (*local_close)(FILE *); FILE *local_fp = f->f_fp; + char *local_setbuf = f->f_setbuf; if (local_fp != NULL) { local_close = f->f_close; if (local_close != NULL && f->unlocked_count > 0) { @@ -446,10 +447,15 @@ * called. */ f->f_fp = NULL; if (local_close != NULL) { + /* Issue #9295: must temporarily reset f_setbuf so that another + thread doesn't free it when running file_close() concurrently. + Otherwise this close() will crash when flushing the buffer. */ + f->f_setbuf = NULL; Py_BEGIN_ALLOW_THREADS errno = 0; sts = (*local_close)(local_fp); Py_END_ALLOW_THREADS + f->f_setbuf = local_setbuf; if (sts == EOF) return PyErr_SetFromErrno(PyExc_IOError); if (sts != 0)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4