Message 152452 - Python tracker (original) (raw)

On Mon, 2012-01-30 at 23:41 +0000, Martin wrote:

Martin <gzlist@googlemail.com> added the comment:

Has anyone had a chance to try this patch on Windows? Martin? I'm hoping that it doesn't impose a startup cost in the default no-randomization cost, and that any startup cost in the -R case is acceptable.

Just tested as requested. Is the patch against 3.1 for a reason? Can't really be compared to earlier results, but get enough weird outliers that that may not be useful anyway. Also needed the following change:

-+ chunk = Py_MIN(size, INT_MAX); ++ chunk = size > INT_MAX ? INT_MAX : size;

Summary, looks like extra work in the default case is avoided and isn't crippling otherwise, though there were a couple of very odd runs not presented probably due to other disk access.

Thanks for testing this!

Oops, yes: Py_MIN is only present in "default" [it was added to Include/Python.h (as PY_MIN) in 72475:8beaa9a37387 for PEP 393, renamed to Py_MIN in 72489:dacac31460c0, eventually reaching Include/pymacro.h in 72512:36fc514de7f0]

"orig_size" in win32_urandom was apparently unused, so I've removed it.

I also found and fixed an occasional failure in my 2.6 backport of the new test_os.URandomTests.get_urandom_subprocess.

Am attaching 4 patches containing the above changes, plus patches to fix dict/set ordering assumptions that start breaking if you try to run the test suite with randomization enabled: add-randomization-to-2.6-dmalcolm-2012-02-01-001.patch fix-broken-tests-on-2.6-dmalcolm-2012-02-01-001.patch add-randomization-to-3.1-dmalcolm-2012-02-01-001.patch fix-broken-tests-on-3.1-dmalcolm-2012-02-01-001.patch

2.6 also could use the dict-ordering fix for test_symtable that was fixed in 2.7 as 74256:789d59773801

FWIW I'm seeing a failure this failure in test_urllib2, but I also see it with a clean checkout of 2.6:

ERROR: test_invalid_redirect (main.HandlerTests)

Traceback (most recent call last): File "Lib/test/test_urllib2.py", line 963, in test_invalid_redirect MockHeaders({"location": valid_url})) File "/home/david/coding/python-hg/cpython-2.6-hash-randomization/Lib/urllib2.py", line 616, in http_error_302 return self.parent.open(new, timeout=req.timeout) File "/home/david/coding/python-hg/cpython-2.6-hash-randomization/Lib/urllib2.py", line 218, in getattr raise AttributeError, attr AttributeError: timeout