diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f0d1fc4fc..f345ff800 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -91,7 +91,7 @@ jobs: - template: ci/azure-check-minrust.yml parameters: name: minrust - rust_version: 1.28.0 + rust_version: 1.31.0 - template: ci/azure-tsan.yml parameters: diff --git a/ci/azure-tsan.yml b/ci/azure-tsan.yml index 519960f33..1914bdf56 100644 --- a/ci/azure-tsan.yml +++ b/ci/azure-tsan.yml @@ -12,7 +12,7 @@ jobs: steps: - template: azure-install-rust.yml parameters: - rust_version: nightly-2018-11-18 + rust_version: nightly-2019-07-17 - template: azure-patch-crates.yml - script: | diff --git a/ci/tsan b/ci/tsan index a261830fb..1b3d57551 100644 --- a/ci/tsan +++ b/ci/tsan @@ -35,3 +35,10 @@ race:WorkerEntry::set_next_sleeper # This ignores a false positive caused by `thread::park()`/`thread::unpark()`. # See: https://github.com/rust-lang/rust/pull/54806#issuecomment-436193353 race:pthread_cond_destroy + +# Recent rand dependency updates and seeding changes have introduced +# lazy_static's and other racy code. See: +# https://github.com/tokio-rs/tokio/pull/1358#issuecomment-516172383 +race:RandomState*::build_hasher +race:lazy_static:: +race:c2_chacha::guts diff --git a/tokio-fs/Cargo.toml b/tokio-fs/Cargo.toml index a46a6583e..caf4270fa 100644 --- a/tokio-fs/Cargo.toml +++ b/tokio-fs/Cargo.toml @@ -27,8 +27,8 @@ tokio-threadpool = "0.1.3" tokio-io = "0.1.6" [dev-dependencies] -rand = "0.6" -tempfile = ">=3.0.5, <3.1" +rand = "0.7" +tempfile = "~3.1.0" tokio-io = "0.1.6" tokio-codec = "0.1.0" tokio = "0.1.7" diff --git a/tokio-reactor/CHANGELOG.md b/tokio-reactor/CHANGELOG.md index 989d842cd..15b2f8ec7 100644 --- a/tokio-reactor/CHANGELOG.md +++ b/tokio-reactor/CHANGELOG.md @@ -1,3 +1,9 @@ +# 0.1.10 (September 25, 2019) + +### Changed +- Upgrade to parking_lot 0.9.0 (#1298 backport) +- The minimum supported rust version (MSRV) is now 1.31.0. (#1358) + # 0.1.9 (March 1, 2019) ### Added diff --git a/tokio-reactor/Cargo.toml b/tokio-reactor/Cargo.toml index c70d78256..9896b9eb1 100644 --- a/tokio-reactor/Cargo.toml +++ b/tokio-reactor/Cargo.toml @@ -8,13 +8,13 @@ name = "tokio-reactor" # - README.md # - Update CHANGELOG.md. # - Create "v0.1.x" git tag. -version = "0.1.9" +version = "0.1.10" authors = ["Carl Lerche "] license = "MIT" readme = "README.md" repository = "https://github.com/tokio-rs/tokio" homepage = "https://tokio.rs" -documentation = "https://docs.rs/tokio-reactor/0.1.9/tokio_reactor" +documentation = "https://docs.rs/tokio-reactor/0.1.10/tokio_reactor" description = """ Event loop that drives Tokio I/O resources. """ @@ -27,7 +27,7 @@ lazy_static = "1.0.2" log = "0.4.1" mio = "0.6.14" num_cpus = "1.8.0" -parking_lot = "0.7.0" +parking_lot = "0.9.0" slab = "0.4.0" tokio-executor = "0.1.1" tokio-io = "0.1.6" diff --git a/tokio-reactor/README.md b/tokio-reactor/README.md index 7befabda0..1b8d0c046 100644 --- a/tokio-reactor/README.md +++ b/tokio-reactor/README.md @@ -2,7 +2,7 @@ Event loop that drives Tokio I/O resources. -[Documentation](https://docs.rs/tokio-reactor/0.1.9/tokio_reactor) +[Documentation](https://docs.rs/tokio-reactor/0.1.10/tokio_reactor) ## Overview @@ -25,10 +25,10 @@ are building a custom I/O resource. [`mio`]: http://github.com/carllerche/mio [`futures`]: http://github.com/rust-lang-nursery/futures-rs -[`Reactor`]: https://docs.rs/tokio-reactor/0.1.9/tokio_reactor/struct.Reactor.html -[`Handle`]: https://docs.rs/tokio-reactor/0.1.9/tokio_reactor/struct.Handle.html -[`Registration`]: https://docs.rs/tokio-reactor/0.1.9/tokio_reactor/struct.Registration.html -[`PollEvented`]: https://docs.rs/tokio-reactor/0.1.9/tokio_reactor/struct.PollEvented.html +[`Reactor`]: https://docs.rs/tokio-reactor/0.1.10/tokio_reactor/struct.Reactor.html +[`Handle`]: https://docs.rs/tokio-reactor/0.1.10/tokio_reactor/struct.Handle.html +[`Registration`]: https://docs.rs/tokio-reactor/0.1.10/tokio_reactor/struct.Registration.html +[`PollEvented`]: https://docs.rs/tokio-reactor/0.1.10/tokio_reactor/struct.PollEvented.html [`tokio`]: ../ ## License diff --git a/tokio-reactor/src/lib.rs b/tokio-reactor/src/lib.rs index 6b0bf3f67..32180f358 100644 --- a/tokio-reactor/src/lib.rs +++ b/tokio-reactor/src/lib.rs @@ -1,4 +1,4 @@ -#![doc(html_root_url = "https://docs.rs/tokio-reactor/0.1.9")] +#![doc(html_root_url = "https://docs.rs/tokio-reactor/0.1.10")] #![deny(missing_docs, warnings, missing_debug_implementations)] //! Event loop that drives Tokio I/O resources. diff --git a/tokio-sync/Cargo.toml b/tokio-sync/Cargo.toml index bab2a1a00..766f0b149 100644 --- a/tokio-sync/Cargo.toml +++ b/tokio-sync/Cargo.toml @@ -24,7 +24,7 @@ fnv = "1.0.6" futures = "0.1.19" [dev-dependencies] -env_logger = { version = "0.5", default-features = false } +env_logger = { version = "0.6", default-features = false } tokio = { version = "0.1.15", path = "../tokio" } tokio-mock-task = "0.1.1" loom = { version = "0.1.1", features = ["futures"] } diff --git a/tokio-tcp/Cargo.toml b/tokio-tcp/Cargo.toml index cae0f5e5d..4086e5623 100644 --- a/tokio-tcp/Cargo.toml +++ b/tokio-tcp/Cargo.toml @@ -28,6 +28,6 @@ iovec = "0.1" futures = "0.1.19" [dev-dependencies] -env_logger = { version = "0.5", default-features = false } +env_logger = { version = "0.6", default-features = false } net2 = "0.2" tokio = "0.1.13" diff --git a/tokio-threadpool/CHANGELOG.md b/tokio-threadpool/CHANGELOG.md index e0109a8ce..59dfa3c75 100644 --- a/tokio-threadpool/CHANGELOG.md +++ b/tokio-threadpool/CHANGELOG.md @@ -1,3 +1,11 @@ +# 0.1.16 (September 25, 2019) + +### Changed +- Remove last non-dev dependency on rand crate by seeding PRNG via libstd + `RandomState` (#1324 backport) +- Upgrade (dev-only dependency) rand to 0.7.0 (#1302 backport) +- The minimum supported rust version (MSRV) is now 1.31.0 (#1358) + # 0.1.15 (June 2, 2019) ### Changed diff --git a/tokio-threadpool/Cargo.toml b/tokio-threadpool/Cargo.toml index d74e7476a..0f7a48272 100644 --- a/tokio-threadpool/Cargo.toml +++ b/tokio-threadpool/Cargo.toml @@ -8,8 +8,8 @@ name = "tokio-threadpool" # - README.md # - Update CHANGELOG.md. # - Create "v0.1.x" git tag. -version = "0.1.15" -documentation = "https://docs.rs/tokio-threadpool/0.1.14/tokio_threadpool" +version = "0.1.16" +documentation = "https://docs.rs/tokio-threadpool/0.1.16/tokio_threadpool" repository = "https://github.com/tokio-rs/tokio" homepage = "https://github.com/tokio-rs/tokio" license = "MIT" @@ -27,12 +27,13 @@ crossbeam-deque = "0.7.0" crossbeam-queue = "0.1.0" crossbeam-utils = "0.6.4" num_cpus = "1.2" -rand = "0.6" slab = "0.4.1" log = "0.4" +lazy_static = "1" [dev-dependencies] -env_logger = "0.5" +rand = "0.7" +env_logger = { version = "0.6", default-features = false } # For comparison benchmarks futures-cpupool = "0.1.7" diff --git a/tokio-threadpool/README.md b/tokio-threadpool/README.md index d85afbaaf..8ce7fa8cf 100644 --- a/tokio-threadpool/README.md +++ b/tokio-threadpool/README.md @@ -3,7 +3,7 @@ A library for scheduling execution of futures concurrently across a pool of threads. -[Documentation](https://docs.rs/tokio-threadpool/0.1.15/tokio_threadpool) +[Documentation](https://docs.rs/tokio-threadpool/0.1.16/tokio_threadpool) ### Why not Rayon? diff --git a/tokio-threadpool/src/lib.rs b/tokio-threadpool/src/lib.rs index c53afb588..97cfb9060 100644 --- a/tokio-threadpool/src/lib.rs +++ b/tokio-threadpool/src/lib.rs @@ -1,4 +1,4 @@ -#![doc(html_root_url = "https://docs.rs/tokio-threadpool/0.1.15")] +#![doc(html_root_url = "https://docs.rs/tokio-threadpool/0.1.16")] #![deny(warnings, missing_docs, missing_debug_implementations)] //! A work-stealing based thread pool for executing futures. @@ -84,8 +84,9 @@ extern crate crossbeam_queue; extern crate crossbeam_utils; #[macro_use] extern crate futures; +#[macro_use] +extern crate lazy_static; extern crate num_cpus; -extern crate rand; extern crate slab; #[macro_use] diff --git a/tokio-threadpool/src/pool/mod.rs b/tokio-threadpool/src/pool/mod.rs index 929178354..0a42359b3 100644 --- a/tokio-threadpool/src/pool/mod.rs +++ b/tokio-threadpool/src/pool/mod.rs @@ -17,6 +17,8 @@ use worker::{self, Worker, WorkerId}; use futures::Poll; use std::cell::Cell; +use std::collections::hash_map::RandomState; +use std::hash::{BuildHasher, Hash, Hasher}; use std::num::Wrapping; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering::{AcqRel, Acquire}; @@ -25,7 +27,6 @@ use std::thread; use crossbeam_deque::Injector; use crossbeam_utils::CachePadded; -use rand; #[derive(Debug)] pub(crate) struct Pool { @@ -420,11 +421,7 @@ impl Pool { /// Uses a thread-local random number generator based on XorShift. pub fn rand_usize(&self) -> usize { thread_local! { - static RNG: Cell> = { - // The initial seed must be non-zero. - let init = rand::random::() | 1; - Cell::new(Wrapping(init)) - } + static RNG: Cell> = Cell::new(Wrapping(prng_seed())); } RNG.with(|rng| { @@ -448,3 +445,31 @@ impl PartialEq for Pool { unsafe impl Send for Pool {} unsafe impl Sync for Pool {} + +// Return a thread-specific, 32-bit, non-zero seed value suitable for a 32-bit +// PRNG. This uses one libstd RandomState for a default hasher and hashes on +// the current thread ID to obtain an unpredictable, collision resistant seed. +fn prng_seed() -> u32 { + // This obtains a small number of random bytes from the host system (for + // example, on unix via getrandom(2)) in order to seed an unpredictable and + // HashDoS resistant 64-bit hash function (currently: `SipHasher13` with + // 128-bit state). We only need one of these, to make the seeds for all + // process threads different via hashed IDs, collision resistant, and + // unpredictable. + lazy_static! { + static ref RND_STATE: RandomState = RandomState::new(); + } + + // Hash the current thread ID to produce a u32 value + let mut hasher = RND_STATE.build_hasher(); + thread::current().id().hash(&mut hasher); + let hash: u64 = hasher.finish(); + let seed = (hash as u32) ^ ((hash >> 32) as u32); + + // Ensure non-zero seed (Xorshift yields only zero's for that seed) + if seed == 0 { + 0x9b4e_6d25 // misc bits, could be any non-zero + } else { + seed + } +} diff --git a/tokio-timer/Cargo.toml b/tokio-timer/Cargo.toml index 85db73992..3ee921633 100644 --- a/tokio-timer/Cargo.toml +++ b/tokio-timer/Cargo.toml @@ -28,6 +28,6 @@ crossbeam-utils = "0.6.0" slab = "0.4.1" [dev-dependencies] -rand = "0.6" +rand = "0.7" tokio-mock-task = "0.1.0" tokio = "0.1.7" diff --git a/tokio-tls/Cargo.toml b/tokio-tls/Cargo.toml index 3d48213d5..541988537 100644 --- a/tokio-tls/Cargo.toml +++ b/tokio-tls/Cargo.toml @@ -31,7 +31,7 @@ tokio-io = "0.1.7" [dev-dependencies] tokio = "0.1" cfg-if = "0.1" -env_logger = { version = "0.5", default-features = false } +env_logger = { version = "0.6", default-features = false } [target.'cfg(all(not(target_os = "macos"), not(windows), not(target_os = "ios")))'.dev-dependencies] openssl = "0.10" diff --git a/tokio-udp/Cargo.toml b/tokio-udp/Cargo.toml index a64d4ecfd..6b09f84ba 100644 --- a/tokio-udp/Cargo.toml +++ b/tokio-udp/Cargo.toml @@ -29,4 +29,4 @@ log = "0.4" futures = "0.1.19" [dev-dependencies] -env_logger = { version = "0.5", default-features = false } +env_logger = { version = "0.6", default-features = false } diff --git a/tokio-uds/Cargo.toml b/tokio-uds/Cargo.toml index 49315000f..591d3003a 100644 --- a/tokio-uds/Cargo.toml +++ b/tokio-uds/Cargo.toml @@ -33,4 +33,4 @@ tokio-io = "0.1.6" [dev-dependencies] tokio = "0.1.6" -tempfile = ">=3.0.5, <3.1" +tempfile = "~3.1.0" diff --git a/tokio/Cargo.toml b/tokio/Cargo.toml index 9a5539813..3b97d5336 100644 --- a/tokio/Cargo.toml +++ b/tokio/Cargo.toml @@ -82,7 +82,7 @@ mio = { version = "0.6.14", optional = true } tokio-uds = { version = "0.2.1", optional = true } [dev-dependencies] -env_logger = { version = "0.5", default-features = false } +env_logger = { version = "0.6", default-features = false } flate2 = { version = ">=1.0.2, <1.0.10", features = ["tokio"] } futures-cpupool = "0.1" http = "0.1"