Skip to content

Commit

Permalink
Fix leaking of Nops
Browse files Browse the repository at this point in the history
We would leak Nops into FuzzIL programs in the
MinimizationPostProcessor that were not removed.
This would lead to Nops being marked as .notRemovable in subsequent
minimization attempts which would break some assertions when trying
to remove Nops as we never expect them to have the .notRemovable
flag set.
  • Loading branch information
carl-smith committed Sep 27, 2024
1 parent fb79747 commit d9b7550
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions Sources/Fuzzilli/Minimization/MinimizationHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class MinimizationHelper {
private static let defaultNumExecutions = 1

init(for aspects: ProgramAspects, forCode code: Code, of fuzzer: Fuzzer, runningOnFuzzerQueue: Bool) {
assert(code.filter({ $0.isNop }).count == 0)
self.aspects = aspects
self.fuzzer = fuzzer
self.runningOnFuzzerQueue = runningOnFuzzerQueue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ struct MinimizationPostProcessor {
// Either we're adding a new instruction (in which case we're replacing a nop inserted in step 1), or changing the number of inputs of an existing instruction.
assert((helper.code[change.index].op is Nop && !(change.newInstruction.op is Nop)) ||
(helper.code[change.index].op.name == change.newInstruction.op.name && helper.code[change.index].numInputs < change.newInstruction.numInputs))
if !helper.tryReplacing(instructionAt: change.index, with: change.newInstruction) {
return false
}
helper.tryReplacing(instructionAt: change.index, with: change.newInstruction)
}

// Step 3: Remove any remaining nops from step 1.
Expand Down
1 change: 1 addition & 0 deletions Sources/Fuzzilli/Minimization/Minimizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public class Minimizer: ComponentBase {
postProcessor.process(with: helper)

assert(helper.code.isStaticallyValid())
assert(!helper.code.contains(where: { $0.isNop }))

return helper.finalize()
}
Expand Down

0 comments on commit d9b7550

Please sign in to comment.