Skip to content

Commit 3a5e38f

Browse files
committed
Minimal fix - just leak allocations
1 parent f7c2d8e commit 3a5e38f

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ jobs:
135135
name: "Miri tests"
136136
runs-on: ubuntu-latest
137137
env:
138-
MIRIFLAGS: "-Zmiri-disable-isolation -Zmiri-strict-provenance -Zmiri-tag-raw-pointers"
138+
MIRIFLAGS: "-Zmiri-disable-isolation -Zmiri-strict-provenance -Zmiri-tag-raw-pointers -Zmiri-ignore-leaks"
139139
steps:
140140
- uses: actions/checkout@v1
141141
- run: rustup toolchain install nightly --profile minimal --component rust-src miri

src/test.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,14 @@ impl<F> DerefMut for OwnedHeap<F> {
4343
pub fn new_heap() -> OwnedHeap<impl Sized> {
4444
const HEAP_SIZE: usize = 1000;
4545
let mut heap_space = Box::new(Chonk::<HEAP_SIZE>::new());
46-
let data = &mut heap_space.data;
46+
let data = &mut Box::leak(heap_space).data;
4747
let assumed_location = data.as_mut_ptr().cast();
4848

4949
let heap = unsafe { Heap::new(data.as_mut_ptr().cast(), data.len()) };
5050
assert_eq!(heap.bottom(), assumed_location);
5151
assert_eq!(heap.size(), align_down_size(HEAP_SIZE, size_of::<usize>()));
52-
5352
let drop = move || {
54-
let _ = heap_space;
53+
// let _ = heap_space;
5554
};
5655
OwnedHeap { heap, _drop: drop }
5756
}
@@ -60,7 +59,7 @@ fn new_max_heap() -> OwnedHeap<impl Sized> {
6059
const HEAP_SIZE: usize = 1024;
6160
const HEAP_SIZE_MAX: usize = 2048;
6261
let mut heap_space = Box::new(Chonk::<HEAP_SIZE_MAX>::new());
63-
let data = &mut heap_space.data;
62+
let data = &mut Box::leak(heap_space).data;
6463
let start_ptr = data.as_mut_ptr().cast();
6564

6665
// Unsafe so that we have provenance over the whole allocation.
@@ -69,19 +68,19 @@ fn new_max_heap() -> OwnedHeap<impl Sized> {
6968
assert_eq!(heap.size(), HEAP_SIZE);
7069

7170
let drop = move || {
72-
let _ = heap_space;
71+
// let _ = heap_space;
7372
};
7473
OwnedHeap { heap, _drop: drop }
7574
}
7675

7776
fn new_heap_skip(ct: usize) -> OwnedHeap<impl Sized> {
7877
const HEAP_SIZE: usize = 1000;
7978
let mut heap_space = Box::new(Chonk::<HEAP_SIZE>::new());
80-
let data = &mut heap_space.data[ct..];
79+
let data = &mut Box::leak(heap_space).data[ct..];
8180
let heap = unsafe { Heap::new(data.as_mut_ptr().cast(), data.len()) };
8281

8382
let drop = move || {
84-
let _ = heap_space;
83+
// let _ = heap_space;
8584
};
8685
OwnedHeap { heap, _drop: drop }
8786
}

0 commit comments

Comments
 (0)