-
Notifications
You must be signed in to change notification settings - Fork 83
Docopt can cause a process to block when used before random pool is initialized #178
Comments
I feel like "don't ever use the default HashMap" probably isn't a good fix for this. :-/ There are oodles of things that use a HashMap, so I can't imagine that Docopt will be the only problem. |
It looks like there was chatter about changing the default hasher for HashMap in rust-lang/rust#27242 and rust-lang/rust#27713. While I agree with you that its not just Docopt that will have this issue this is a concrete example where it causes problems. On some embedded Linux boards that I've got I have had to stop using Docopt for programs that are kicked off by init scripts because it takes about 2 minutes to initialize the random pool and as a result Docopt blocks those programs from starting up for 2 minutes. |
You also wouldn't be able to use |
Right. I was going to open an issue there as well. |
I suspect the more appropriate place to file an issue is on |
This can be closed since rust-lang/rust#33086 landed. |
@cardoe Thanks! :) |
Docopt can cause a process to block if the /dev/urandom pool has not yet been initialized.
Background
On more recent kernels (>3.17), the getrandom syscall has been introduced. This syscall is used by OsRng when getting a random number. The current syscall args cause it to block until the /dev/urandom pool has been initialized. The default implementation of HashMap uses RandomState for its default hasher. RandomState uses the rand crate which blocks until the /dev/urandom pool has been initialized.
System Setup
Ubuntu 15.10
Rust 1.7.0
GDB Backtrace
This may be solved by using a hasher that does not rely on the random pool being initialized.
The text was updated successfully, but these errors were encountered: