Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix pointer aliasing in in_parallel.rs
In `in_parallel_with_slice()`, there's a `&mut *input.0` that creates a `&mut [I]` of the whole slice in `Input`. The same value is created in multiple threads, thus potentially resulting in multiple threads having mutable references to the same value. This patch fixes that by instead only getting mutable pointers to individual values. It does so by storing a `*mut T` in `Input` instead of the current `*mut [I]`, and then using `pointer::add()` to get pointers to individual elements. Thanks to @Ralith for bringing this up and proposing the solution in our review of unsafe code at Google.
- Loading branch information