Commit ed98853
Merge rayon-rs#1010
1010: Fix ownership invalidation of saved scope panics r=cuviper a=cuviper
Miri complained when we tried to reconstruct a panic `Box` from an
`AtomicPtr`, because a later call to `mem::forget` invalidated that
pointer, even though we just meant not to drop it. `ManuallyDrop` is a
way to accomplish that *before* we take the pointer.
```
test scope::test::panic_propagate_nested_scope_spawn - should panic ... error: Undefined Behavior: trying to retag from <547680> for Unique permission at alloc207942[0x0], but that tag does not exist in the borrow stack for this location
--> ~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1014:9
|
1014 | Box(unsafe { Unique::new_unchecked(raw) }, alloc)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| trying to retag from <547680> for Unique permission at alloc207942[0x0], but that tag does not exist in the borrow stack for this location
| this error occurs as part of retag at alloc207942[0x0..0x10]
|
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
help: <547680> was created by a SharedReadWrite retag at offsets [0x0..0x10]
--> rayon-core/src/scope/mod.rs:732:36
|
732 | .compare_exchange(nil, &mut *err, Ordering::Release, Ordering::Relaxed)
| ^^^^^^^^^
help: <547680> was later invalidated at offsets [0x0..0x10] by a Unique retag
--> rayon-core/src/scope/mod.rs:735:25
|
735 | mem::forget(err); // ownership now transferred into self.panic
| ^^^
```
Co-authored-by: Josh Stone <cuviper@gmail.com>1 file changed
+15
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
725 | 725 | | |
726 | 726 | | |
727 | 727 | | |
728 | | - | |
729 | | - | |
730 | | - | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
736 | 742 | | |
737 | 743 | | |
738 | 744 | | |
| |||
0 commit comments