-
Notifications
You must be signed in to change notification settings - Fork 509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Panic in sub_sleeping_thread #883
Comments
I can reproduce this on my Ryzen 7 3800X (8C/16T) running Fedora 34 and Rust 1.54.0 (from both Fedora and
|
I just hit each of these after removing |
Oh, I think this is actually a simple problem... rayon/rayon-core/src/sleep/counters.rs Lines 55 to 56 in 6cd18c0
rayon/rayon-core/src/sleep/counters.rs Lines 70 to 71 in 6cd18c0
So |
926: Enforce THREADS_MAX and expose it with max_num_threads() r=cuviper a=cuviper We have an inherent maximum on the number of threads we can support in a single thread pool, based on the number of `THREADS_BITS` we are using in the atomic sleep counters. However, we were not enforcing this, so a larger pool could be created and end up wrapping the counters. In debug builds this would fail an assertion, otherwise it may lead to errors in the desired sleep and wakeup behavior. We now assert this limit in `Sleep::new`, and also impose it as a soft limit in `Registry::new`, automatically reducing to the maximum. A top-level `pub fn max_num_threads()` returns the maximum for users. At the same time, the value of `THREADS_BITS` is now adjusted for different machine sizes. It was 10 bits everywhere, but 32-bit systems now use 8 bits for max 255 threads (leaving more room for the JEC), while 64-bit systems now use 16 bits for a maximum of 65,535 threads. Fixes #883. Co-authored-by: Josh Stone <[email protected]>
I ran into a panic crash in debug builds when I was running tests with a high number of threads - below is a somewhat minimal repro, I actually don't know why the tokio runtime has to be built but without that line I don't get a repro (the fun of race conditions):
On debug builds this fairly reliably panics with output like:
This is on rayon version "1.5.1" and rayon-core version "1.9.1".
The text was updated successfully, but these errors were encountered: