-
Notifications
You must be signed in to change notification settings - Fork 736
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
Unsound use of unsafe in src/utils/parallelism.rs
#1491
Labels
Comments
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The static variable
USED_PARALLELISM
is accessed inhas_parallelism_been_used
, and modified inMaybeParallelIterator::into_maybe_par_iter
andMaybeParallelBridge::maybe_par_bridge
.All these cases are unsafe because if they are done at the same time from different threads, they could cause a data race which has undefined behaviour.
The issue is that all of these are safe functions, and no checks are made to ensure that the unsafe operations are in fact safe.
This means that it would be possible to cause UB in safe rust by calling these functions from separate threads.
There maybe reasons to believe that this is unlikely or impossible given the rest of the library (I don't know the code base well enough to say), but that does not change the fact that this is unsound.
The easiest way to fix this would be to place the variable in a
Mutex
. I propose an implementation of this in #1492 .The text was updated successfully, but these errors were encountered: