Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a bug that could leave the coroutine scheduler's PRNG in an inval…
…id state (Kotlin#4052) A potential bug is fixed, where `nextInt` would always return zero due to incorrect initialization of rngState with zero. This could happen during the creation of a worker with thread id = `1595972770` (JDK >=8), or unpredictable if fallback thread-local random is used (android SDK <34 or JDK <7), approximate probability is 2.4E-10 Also, this slightly optimizes the performance of coroutines initialization. During the creation of `CoroutineScheduler.Worker`, we need to initialize its embedded random number generator. To avoid additional class-loading costs (Kotlin#4051), `rngState` is now directly initialized from the current nanoTime (that is used as seed). Fixes Kotlin#4051 Co-authored-by: Vsevolod Tolstopyatov <[email protected]>
- Loading branch information