Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

benchmark mode: until first bug or until timeout #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/Fuzz/Fuzz.fs
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,21 @@ let rec private fuzzLoop opt contSpec concQ randQ =
let concQ, randQ = repeatGreyConcolic opt concQ randQ concolicBudget
// Perform random fuzzing
let concQ, randQ = repeatRandFuzz opt contSpec concQ randQ randFuzzBudget
fuzzLoop opt contSpec concQ randQ
if not (TCManage.shallStop opt) then
fuzzLoop opt contSpec concQ randQ

let private fuzzingTimer opt = async {
let timespan = System.TimeSpan (0, 0, 0, opt.Timelimit)
System.Threading.Thread.Sleep (timespan)
printLine "Fuzzing timeout expired."
let private exitWith opt msg =
printLine msg
if opt.CheckOptionalBugs then TCManage.checkFreezingEtherBug ()
log "===== Statistics ====="
TCManage.printStatistics ()
log "Done, clean up and exit..."
exit (0)

let private fuzzingTimer opt = async {
let timespan = System.TimeSpan (0, 0, 0, opt.Timelimit)
System.Threading.Thread.Sleep (timespan)
exitWith opt "Fuzzing timeout expired."
}

let run args =
Expand All @@ -147,3 +151,4 @@ let run args =
let randQ = List.fold RandFuzzQueue.enqueue (RandFuzzQueue.init ()) initSeeds
log "Start main fuzzing phase"
fuzzLoop opt contSpec concQ randQ
exitWith opt "Fuzzing Stopped"
7 changes: 6 additions & 1 deletion src/Fuzz/Options.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type FuzzerCLI =
| [<Unique>] NoDDFA
| [<Unique>] CheckOptionalBugs
| [<Unique>] UseOthersOracle
| [<Unique>] BenchToBug
with
interface IArgParserTemplate with
member s.Usage =
Expand All @@ -29,6 +30,7 @@ with
| UseOthersOracle ->
"Report bugs using other tools' oracles as well.\n\
Currently we support (BD/IB/ME/RE) X (sFuzz/ILF/Mythril/MANTICORE)."
| BenchToBug -> "stop analysis after first bug found"

type FuzzOption = {
Verbosity : int
Expand All @@ -40,6 +42,7 @@ type FuzzOption = {
DynamicDFA : bool
CheckOptionalBugs : bool
UseOthersOracle : bool
BenchToBug : bool
}

let parseFuzzOption (args: string array) =
Expand All @@ -55,4 +58,6 @@ let parseFuzzOption (args: string array) =
StaticDFA = not (r.Contains(<@ NoSDFA @>)) // Enabled by default.
DynamicDFA = not (r.Contains(<@ NoDDFA @>)) // Enabled by default.
CheckOptionalBugs = r.Contains(<@ CheckOptionalBugs @>)
UseOthersOracle = r.Contains(<@ UseOthersOracle @>) }
UseOthersOracle = r.Contains(<@ UseOthersOracle @>)
BenchToBug = r.Contains(<@ BenchToBug @>)
}
2 changes: 2 additions & 0 deletions src/Fuzz/TCManage.fs
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,5 @@ let evalAndSave opt seed =
if not covGain && duGain && opt.Verbosity >= 2 then
log "[*] Internal new seed: %s" (Seed.toString seed)
covGain || duGain // Returns whether this seed is meaningful.

let shallStop opt = (opt.BenchToBug && totalBug > 0)