Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 2247 by Deadlock when calling 'patch' with a very large diff

* NOTE: Do not post confidential information in this bug report. *
*       If you need immediate support, please contact            *
*                             *

What version are you running?


We often have a high memory consumption on our reviewboard server, and when it happens, there are some 'patch' processes blocked.

I looked at how you launch the 'patch' utility, and I think that there is a potential pb, due to the use of Popen.wait() with pipes. According to the documentation (, there is a potential deadlock if the date sent to the pipe is larger than the pipe buffer size (we have some very huge diffs).

Here is a small python code to reproduce it:

import sys, subprocess

def main():

  data = ""
  for i in range(100000):
    data += "%d\n" % i

p = subprocess.Popen(['cat'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
  output =
  failure = p.wait()

  if failure:


if __name__ == '__main__': main()

As long as 'data' is small enough (i.e. with a small maximum value of 'i'), everything works well. But with 'i' ranging from 0 to 100000, p.wait() blocks.

The documentation recommends to use Popen.communicate()

You received this message because you are subscribed to the Google Groups 
"reviewboard-issues" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to