Skip to content

Commit 4149849

Browse files
committed
fuzz: remove potential undefined behavior in chaos harness
The chaos harness has a potential UB bug reported by Miri due to mutable pointer aliasing. The `heap` object has a mutable reference to `HEAP_MEM`, which gets invalidated when calculating `remaining_space`, as it does so through a mut pointer. Thus, using `heap` after using the pointer is technically undefined behavior under Rust's aliasing rules. Fix this by taking a const pointer. Note that it is very unlikely this caused any actual issues under the current state of the compiler. Signed-off-by: Carlos López <[email protected]>
1 parent 3c9bafa commit 4149849

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fuzz/fuzz_targets/chaos.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fn fuzz(size: u16, actions: Vec<Action>) {
8282
// safety: new heap size never exceeds MAX_HEAP_SIZE
8383
unsafe {
8484
let remaining_space = HEAP_MEM
85-
.as_mut_ptr()
85+
.as_ptr()
8686
.add(MAX_HEAP_SIZE)
8787
.offset_from(heap.top());
8888
assert!(remaining_space >= 0);

0 commit comments

Comments
 (0)