Permalink
Please sign in to comment.
Browse files
Fix bug where we would overwrite existing file descriptors with dup2().
Now we check file descriptors (even those above #10) before using them. This is a recurrence of the bug described here: http://www.oilshell.org/blog/2017/07/02.html If you do 'import random' in Python, it results in /dev/urandom being permanently open (which can be seen in the blog post!) At the time, I incorrectly fixed the bug by just opening our own descriptors above #10. But it's possible that CPython will subsequently open something above #10 (/dev/urandom appeared as #12), so we have to additionally check descriptors before we use them. NOTE: 'import cgi' eventually causes 'import random'. We're only using it for cgi.escape(), but cgi.FieldStorage() uses tempfile, which uses a random number generator. Also: minimize the test case as gold/configure-bug.sh. 'test/gold.sh configure' was the case that caught this bug. The spec tests didn't find it! Because it appears to take about 4 redirects for this to happen!
- Loading branch information...
Showing
with
36 additions
and 8 deletions.
- +22 −8 core/process.py
- +13 −0 gold/configure-bug.sh
- +1 −0 test/gold.sh
| @@ -0,0 +1,13 @@ | ||
| #!/bin/bash | ||
| detect_readline() { | ||
| echo foo >/dev/null 2>&1 | ||
| echo "two" 1>&2 | ||
| } | ||
| main() { | ||
| detect_readline > _tmp/f2-out.txt | ||
| #detect_readline | ||
| } | ||
| main "$@" |
0 comments on commit
94c7d78