[issue815646] thread unsafe file objects cause crash

Antoine Pitrou report at bugs.python.org
Fri Mar 28 23:45:08 CET 2008


Antoine Pitrou <pitrou at free.fr> added the comment:

Why hadn't I read #595601 in detail, it has an explanation: 

[quoting Jeremy Hylton]
The universal newline code is squirrels the FILE * in a
local variable, which is worse.  If it happens that
another thread closes the file, at best the local
points to a closed FILE *.  But that memory could get
recycled and then there's no way to know what it points to.
[/quoting]

Even with careful coding, there's a small window between releasing the
GIL on our side, and acquiring the FILE-specific lock in the glibc,
during which the fclose() function can be invoked and release the FILE
just before we invoke another function (e.g. fseek()) on it.

____________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue815646>
____________________________________


More information about the Python-bugs-list mailing list