| Subject: | RAND_poll can be incredibly slow on Windows7 due to Heap32Next |
| Date: | Fri, 13 Nov 2009 02:20:00 +0000 |
| To: | "rt@openssl.org" <rt@openssl.org> |
| From: | James Baker <jbaker@tableausoftware.com> |
Message body is not shown because sender requested not to inline it.
bug report (first time, please forgive any faux-paus)
64-bit Windows 7 Ultimate
affects openssl/crypto/rand/rand_win.c from at least 2005 (v1.4.5) to current 0.9.8 and 1.0.0
Even when doing the absolute minimum heap traversal, RAND_poll walks the first 80 entries of the first heap list to generate entropy without checking how much time it's taking. This can easily take more than a minute to execute with a moderate-to-large heap size.
Expected behavior: RAND_poll needs to be limited to taking only a few seconds while still gathering enough entropy. Suggested remedies: A) find an alternate method of heap list traversal or B) find an alternate source of entropy
The cause is the usage of Heap32Next: my testing shows that performance of Heap32Next is linear w/r/t the number of heap entries in the first heap list. Each invocation of Heap32Next (on Win7, contrasted with XP and Vista) can easily take more than 1 second - graphs of the performance of Heap32Next are here: http://thenewjamesbaker.blogspot.com/2009/11/performance-of-heap32next-on-64-bit.html
This report springs from this openssl-users thread: http://groups.google.com/group/mailing.openssl.users/browse_thread/thread/b38d72135da93951/d3cf46fe6311ddbb
Attached is rand_win.cpp, a test harness I used in MSVC2005 to instrument a stripped-down version of RAND_poll.
64-bit Windows 7 Ultimate
affects openssl/crypto/rand/rand_win.c from at least 2005 (v1.4.5) to current 0.9.8 and 1.0.0
Even when doing the absolute minimum heap traversal, RAND_poll walks the first 80 entries of the first heap list to generate entropy without checking how much time it's taking. This can easily take more than a minute to execute with a moderate-to-large heap size.
Expected behavior: RAND_poll needs to be limited to taking only a few seconds while still gathering enough entropy. Suggested remedies: A) find an alternate method of heap list traversal or B) find an alternate source of entropy
The cause is the usage of Heap32Next: my testing shows that performance of Heap32Next is linear w/r/t the number of heap entries in the first heap list. Each invocation of Heap32Next (on Win7, contrasted with XP and Vista) can easily take more than 1 second - graphs of the performance of Heap32Next are here: http://thenewjamesbaker.blogspot.com/2009/11/performance-of-heap32next-on-64-bit.html
This report springs from this openssl-users thread: http://groups.google.com/group/mailing.openssl.users/browse_thread/thread/b38d72135da93951/d3cf46fe6311ddbb
Attached is rand_win.cpp, a test harness I used in MSVC2005 to instrument a stripped-down version of RAND_poll.