{"action":"created","issue":{"url":"https://api.github.com/repos/docopt/docopt.rs/issues/178","repository_url":"https://api.github.com/repos/docopt/docopt.rs","labels_url":"https://api.github.com/repos/docopt/docopt.rs/issues/178/labels{/name}","comments_url":"https://api.github.com/repos/docopt/docopt.rs/issues/178/comments","events_url":"https://api.github.com/repos/docopt/docopt.rs/issues/178/events","html_url":"https://github.com/docopt/docopt.rs/issues/178","id":148365169,"number":178,"title":"Docopt can cause a process to block when used before random pool is initialized ","user":{"login":"derekstraka","id":9665276,"avatar_url":"https://avatars.githubusercontent.com/u/9665276?v=3","gravatar_id":"","url":"https://api.github.com/users/derekstraka","html_url":"https://github.com/derekstraka","followers_url":"https://api.github.com/users/derekstraka/followers","following_url":"https://api.github.com/users/derekstraka/following{/other_user}","gists_url":"https://api.github.com/users/derekstraka/gists{/gist_id}","starred_url":"https://api.github.com/users/derekstraka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derekstraka/subscriptions","organizations_url":"https://api.github.com/users/derekstraka/orgs","repos_url":"https://api.github.com/users/derekstraka/repos","events_url":"https://api.github.com/users/derekstraka/events{/privacy}","received_events_url":"https://api.github.com/users/derekstraka/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-04-14T13:42:02Z","updated_at":"2016-05-06T13:38:18Z","closed_at":null,"body":"Docopt can cause a process to block if the /dev/urandom pool has not yet been initialized.\r\n\r\n## Background\r\nOn more recent kernels (>3.17), the [getrandom](http://man7.org/linux/man-pages/man2/getrandom.2.html) syscall has been introduced.  This syscall is used by [OsRng] (https://github.com/rust-lang-nursery/rand/blob/master/src/os.rs#L62) 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](https://github.com/rust-lang/rust/blob/master/src/libstd/collections/hash/map.rs#L333) uses [RandomState] (https://github.com/rust-lang/rust/blob/master/src/libstd/collections/hash/map.rs#L1653) for its default hasher.  RandomState uses the rand crate which blocks until the /dev/urandom pool has been initialized.\r\n\r\n## System Setup\r\nUbuntu 15.10\r\nRust 1.7.0\r\n\r\n## GDB Backtrace\r\n```rust\r\nCatchpoint 1 (call to syscall 318), syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38\r\n38\t../sysdeps/unix/sysv/linux/x86_64/syscall.S: No such file or directory.\r\n(gdb) bt\r\n#0  syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38\r\n#1  0x00005555558190f5 in rand::StdRng::new::h7f6f37b37bd8a656XMy ()\r\n#2  0x0000555555819446 in rand::thread_rng::THREAD_RNG_KEY::__init::hee923a4dca76e52cqQy ()\r\n#3  0x0000555555801fee in rand::thread_rng::hf965b6c3dc392e76dQy ()\r\n#4  0x0000555555629888 in docopt::collections::hash::map::RandomState::new () at ../src/libstd/collections/hash/map.rs:1638\r\n#5  0x0000555555629864 in docopt::collections::hash::map::RandomState.Default::default () at ../src/libstd/collections/hash/map.rs:1656\r\n#6  0x000055555562ee6f in docopt::collections::hash::map::HashMap<K, V, S>.Default::default () at ../src/libstd/collections/hash/map.rs:1261\r\n#7  0x000055555562ee44 in docopt::collections::hash::map::HashMap<K, V, RandomState>::new () at ../src/libstd/collections/hash/map.rs:512\r\n#8  0x000055555562edef in docopt::synonym::SynonymMap<K, V>::new () at /root/.cargo/registry/src/github.com-88ac128001ac3a9a/docopt-0.6.78/src/synonym.rs:17\r\n#9  0x000055555562e704 in docopt::parse::Parser::new (doc=...) at /root/.cargo/registry/src/github.com-88ac128001ac3a9a/docopt-0.6.78/src/parse.rs:78\r\n#10 0x00005555555cb238 in myprog::dopt::Docopt::new<&str> (usage=...) at /root/.cargo/registry/src/github.com-88ac128001ac3a9a/docopt-0.6.78/src/dopt.rs:177\r\n#11 0x00005555555c7dc2 in myprog::main () at src/main.rs:101\r\n#12 0x0000555555818505 in sys_common::unwind::try::try_fn::h9896872240422604242 ()\r\n#13 0x00005555558157a9 in __rust_try ()\r\n#14 0x0000555555818191 in rt::lang_start::h0d9dcd8707a91319Uoy ()\r\n#15 0x00005555555f518a in main () at ../src/libcollections/string.rs:1734\r\n\r\n```\r\n\r\nThis may be solved by using a hasher that does not rely on the random pool being initialized."},"comment":{"url":"https://api.github.com/repos/docopt/docopt.rs/issues/comments/217442916","html_url":"https://github.com/docopt/docopt.rs/issues/178#issuecomment-217442916","issue_url":"https://api.github.com/repos/docopt/docopt.rs/issues/178","id":217442916,"user":{"login":"cardoe","id":8839,"avatar_url":"https://avatars.githubusercontent.com/u/8839?v=3","gravatar_id":"","url":"https://api.github.com/users/cardoe","html_url":"https://github.com/cardoe","followers_url":"https://api.github.com/users/cardoe/followers","following_url":"https://api.github.com/users/cardoe/following{/other_user}","gists_url":"https://api.github.com/users/cardoe/gists{/gist_id}","starred_url":"https://api.github.com/users/cardoe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cardoe/subscriptions","organizations_url":"https://api.github.com/users/cardoe/orgs","repos_url":"https://api.github.com/users/cardoe/repos","events_url":"https://api.github.com/users/cardoe/events{/privacy}","received_events_url":"https://api.github.com/users/cardoe/received_events","type":"User","site_admin":false},"created_at":"2016-05-06T13:38:18Z","updated_at":"2016-05-06T13:38:18Z","body":"This can be closed since rust-lang/rust#33086 landed."}}