ramkrishanbhatt / modwsgi

Automatically exported from code.google.com/p/modwsgi
0 stars 0 forks source link

Use of sys.stderr from multiple threads may cause crash #30

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by Graham.Dumpleton@gmail.com on 21 Sep 2007 at 12:51

GoogleCodeExporter commented 8 years ago
Version 1.1 of mod_wsgi includes fix for this issue.

Original comment by Graham.Dumpleton@gmail.com on 1 Oct 2007 at 3:22