Skip to content

Commit 8e9b7a6

Browse files
author
Michael Rodler
committed
got sancov 8bit to work by avoiding calling clone on OwnedMutSlice and instead constructing a new ones from the raw parts of the pointers.
1 parent 53efc58 commit 8e9b7a6

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

cargo-libafl/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ rustc_version = "0.4"
3030
xdg = "2.4"
3131

3232
[features]
33+
default = ["sancov_8bit"]
3334
sancov_8bit = []
3435
tui = []

cargo-libafl/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ fn main() {
5151
cmd.current_dir(&out_path)
5252
.env("CARGO_TARGET_DIR", out_path.join("rt"))
5353
.arg("build");
54+
cmd.arg("--no-default-features");
5455
#[cfg(feature = "sancov_8bit")]
5556
cmd.arg("--features").arg("sancov_8bit");
5657
#[cfg(feature = "tui")]

cargo-libafl/cargo-libafl-runtime/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ crate-type = ["staticlib", "rlib"]
3333
path = "runtime.rs"
3434

3535
[features]
36+
default = [ "sancov_8bit" ]
3637
sancov_8bit = []
3738
tui = []

cargo-libafl/cargo-libafl-runtime/runtime.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use libafl::{
1616
rands::StdRand,
1717
shmem::{ShMemProvider, StdShMemProvider},
1818
tuples::{tuple_list, Merge},
19-
AsSlice,
19+
AsMutSlice, AsSlice,
2020
},
2121
corpus::{self, CachedOnDiskCorpus, Corpus, OnDiskCorpus},
2222
events::EventConfig,
@@ -36,6 +36,7 @@ use libafl::{
3636
StdMOptMutator,
3737
},
3838
observers::{BacktraceObserver, TimeObserver},
39+
prelude::OwnedMutSlice,
3940
schedulers::{
4041
powersched::PowerSchedule, IndexesLenTimeMinimizerScheduler, PowerQueueScheduler,
4142
},
@@ -218,9 +219,16 @@ pub fn main() {
218219

219220
#[cfg(feature = "sancov_8bit")]
220221
let edges_observer = {
221-
let edges = unsafe { &mut COUNTERS_MAPS };
222-
// TODO: is the call to edges.clone here the reason for breaking sancov_8bit?
223-
HitcountsIterableMapObserver::new(MultiMapObserver::new("edges", edges.clone()))
222+
let maps_vec = unsafe { &mut COUNTERS_MAPS };
223+
let edges = maps_vec
224+
.iter_mut()
225+
.map(|map| {
226+
let l = map.as_slice().len();
227+
let p = map.as_mut_slice().as_mut_ptr();
228+
unsafe { OwnedMutSlice::from_raw_parts_mut(p, l) }
229+
})
230+
.collect();
231+
HitcountsIterableMapObserver::new(MultiMapObserver::new("edges", edges))
224232
};
225233

226234
#[cfg(not(feature = "sancov_8bit"))]

0 commit comments

Comments
 (0)