In mod_wsgi the sys.stderr (and sys.stdout if not restricted) stream
objects are replaced with alternatives which will ensure that any output is
flushed out into the Apache error logs whenever a new line is encountered
in the output.
Where sys.stderr is being used to output messages by multiple threads at
the same time and each is emitting a string which is not terminated by a
new line, but where the string contains an embedded new line in the middle
of the string, there is a possibility that part of the output will be lost
or duplicated. In the worst case scenario, an attempt could be made to call
free() with a NULL pointer, which could result in the process crashing.
For this to occur the separate threads must have entered the write()
function at the same time and for the above condition to be satisfied.
Since the probability of this is very low, at present that the problem can
occur is theoretical based on code inspection and no problem has actually
reported by any user.
Note that technically this problem could manifest with wsgi.errors stream
object passed in WSGI environment, but even smaller probability that it
would be encountered in that case, as typically only the thread handling
the request would be accessing that stream object.
Patch for mod_wsgi.c attached if wanting to address problem before next
release.
Original issue reported on code.google.com by Graham.Dumpleton@gmail.com on 7 Sep 2007 at 8:55
Original issue reported on code.google.com by
Graham.Dumpleton@gmail.com
on 7 Sep 2007 at 8:55Attachments: