<div dir="ltr">I was just running the top-level suite, with `lit -sv tests`.<div><br></div><div>However, I was able to reproduce the deadlock I saw by just adding this to util.py:</div><div>--</div><div>+if __name__ == '__main__':</div><div>+ print 'running watchdog test.'</div><div>+ executeCommand(['/bin/bash',</div><div>+ '/Volumes/Data/ddunbar/llvm/utils/lit/tests/Inputs/timeout/Output/infloop.py.script'],</div><div>+ None, None, 0.1)</div><div>+ raise SystemExit</div><div>--</div><div><br></div><div>This was with Python 2.7.6, which might matter.</div><div><br></div><div> - Daniel</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 6, 2015 at 8:55 AM, Jonathan Roelofs <span dir="ltr"><<a href="mailto:jonathan@codesourcery.com" target="_blank">jonathan@codesourcery.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
> I investigate a little bit, and I believe what happens is that executeCommand() is hanging in p.communicate(), because the file descriptors haven't necessarily been closed. It did look like I could fix this by explicitly forcing a close on the file descriptors in _safely_kill(), e.g.:<br>
<br>
><br>
<br>
> os.close(popen.stdout.fileno())<br>
<br>
> os.close(popen.stderr.fileno())<br>
<br>
><br>
<br>
> but I'm not confident that is reliable.<br>
<br>
<br>
How are you running the testsuite? I've been copy-pasting the command that the makefile runs, and adding --timeout=1 to it.<br>
<br>
> Getting the kind of behavior right is tricky, esp. while trying to be cross platform, and getting it right in Python where it isn't obvious what layers like subprocess() are doing makes me nervous. Also, I know there are some gotchas here on Windows that I would want to know are covered. Do you have access to all three major platforms to test this logic on?<br>
<br>
<br>
Tested on Darwin14, and Ubuntu10.04... Seems to work there for me without closing the FDs. I don't have a windows box to check this on.<br>
<br>
(Python is 2.7.9 on the Darwin machine, and 2.7.3 on the Ubuntu machine.)<br>
<br>
> Also, note that kill() will deadlock if it is ever called since both it and _handler() try to take the lock. In this example, it means that if I Ctrl-C lit after it hangs in the above then it will deadlock in the context manager __exit__ function.<br>
<br>
<br>
This revision fixes the deadlock on kill(). Ctrl-C seems to DTRT.<br>
<br>
<br>
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D6584&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=-MYxDj5LtYSoS6TYkxKBtKQuMcJmX5Hw2KwrKpX1YoY&s=NLEmg1dQ3l7uHl9dS5psukF0w1kLqlT_IyYlxYiccME&e=" rel="noreferrer" target="_blank">http://reviews.llvm.org/D6584</a><br>
<br>
Files:<br>
utils/lit/lit/LitConfig.py<br>
utils/lit/lit/TestRunner.py<br>
utils/lit/lit/formats/base.py<br>
utils/lit/lit/main.py<br>
utils/lit/lit/util.py<br>
utils/lit/tests/Inputs/timeout/infloop.py<br>
utils/lit/tests/Inputs/timeout/lit.cfg<br>
utils/lit/tests/Inputs/timeout/short.py<br>
utils/lit/tests/timeout.py<br>
<br>
</blockquote></div><br></div>