about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-01-05 15:05:44 +0100
committerGitHub <noreply@github.com>2022-01-05 15:05:44 +0100
commit56d11a446b6d141612ff5130f0bf3366c4ace845 (patch)
tree5e0c434aa8ae68a695fb339a5535ac5e171f2520 /compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp
parent936ce3dab7fd042101767c439362310f8355e859 (diff)
parenta5a91c8e0732753de7c028182cbb02901fe1b608 (diff)
downloadrust-56d11a446b6d141612ff5130f0bf3366c4ace845.tar.gz
rust-56d11a446b6d141612ff5130f0bf3366c4ace845.zip
Rollup merge of #92092 - saethlin:fix-sort-guards-sb, r=danielhenrymantilla
Drop guards in slice sorting derive src pointers from &mut T, which is invalidated by interior mutation in comparison

I tried to run https://github.com/rust-lang/miri-test-libstd on `alloc` with `-Zmiri-track-raw-pointers`, and got a failure on the test `slice::panic_safe`. The test failure has nothing to do with panic safety, it's from how the test tests for panic safety.

I minimized the test failure into this very silly program:
```rust
use std::cell::Cell;
use std::cmp::Ordering;

#[derive(Clone)]
struct Evil(Cell<usize>);

fn main() {
    let mut input = vec![Evil(Cell::new(0)); 3];

    // Hits the bug pattern via CopyOnDrop in core
    input.sort_unstable_by(|a, _b| {
        a.0.set(0);
        Ordering::Less
    });

    // Hits the bug pattern via InsertionHole in alloc
    input.sort_by(|_a, b| {
        b.0.set(0);
        Ordering::Less
    });
}
```

To fix this, I'm just removing the mutability/uniqueness where it wasn't required.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp')
0 files changed, 0 insertions, 0 deletions