Global Metrics
path: .metrics.mi.mi_visual_studio
old: 15.74906104068961
new: 22.979780837791058
path: .metrics.mi.mi_original
old: 26.93089437957923
new: 39.295425232622705
path: .metrics.mi.mi_sei
old: 4.328171883770068
new: 4.51531071087906
path: .metrics.cyclomatic.sum
old: 26.0
new: 21.0
path: .metrics.cyclomatic.average
old: 1.04
new: 1.4
path: .metrics.cognitive.sum
old: 0.0
new: 5.0
path: .metrics.cognitive.average
old: 0.0
new: 0.5
path: .metrics.halstead.n2
old: 178.0
new: 130.0
path: .metrics.halstead.length
old: 802.0
new: 591.0
path: .metrics.halstead.N2
old: 354.0
new: 219.0
path: .metrics.halstead.effort
old: 90824.12749452412
new: 79377.01624240298
path: .metrics.halstead.level
old: 0.06704331450094163
new: 0.05396430053964301
path: .metrics.halstead.time
old: 5045.784860806896
new: 4409.834235689054
path: .metrics.halstead.vocabulary
old: 193.0
new: 152.0
path: .metrics.halstead.purity_ratio
old: 1.7322742015537989
new: 1.7106858059284595
path: .metrics.halstead.N1
old: 448.0
new: 372.0
path: .metrics.halstead.estimated_program_length
old: 1389.2839096461466
new: 1011.0153113037196
path: .metrics.halstead.bugs
old: 0.6735133910279756
new: 0.615661399477237
path: .metrics.halstead.difficulty
old: 14.915730337078651
new: 18.53076923076923
path: .metrics.halstead.n1
old: 15.0
new: 22.0
path: .metrics.halstead.volume
old: 6089.150543889001
new: 4283.525160445159
path: .metrics.nexits.average
old: 0.875
new: 0.6
path: .metrics.nexits.sum
old: 7.0
new: 6.0
path: .metrics.nargs.sum
old: 11.0
new: 0.0
path: .metrics.nargs.average
old: 1.375
new: 0.0
path: .metrics.loc.cloc
old: 99.0
new: 14.0
path: .metrics.loc.sloc
old: 307.0
new: 172.0
path: .metrics.loc.blank
old: 55.0
new: 29.0
path: .metrics.loc.lloc
old: 7.0
new: 14.0
path: .metrics.loc.ploc
old: 153.0
new: 129.0
path: .metrics.nom.functions
old: 8.0
new: 10.0
path: .metrics.nom.total
old: 8.0
new: 10.0
Spaces Data
Minimal test - lines (28, 170)
path: .spaces[0].metrics.cyclomatic.sum
old: 1.0
new: 20.0
path: .spaces[0].metrics.cyclomatic.average
old: 1.0
new: 1.4285714285714286
path: .spaces[0].metrics.loc.ploc
old: 1.0
new: 113.0
path: .spaces[0].metrics.loc.sloc
old: 1.0
new: 143.0
path: .spaces[0].metrics.loc.blank
old: 0.0
new: 27.0
path: .spaces[0].metrics.loc.cloc
old: 0.0
new: 3.0
path: .spaces[0].metrics.loc.lloc
old: 0.0
new: 14.0
path: .spaces[0].metrics.cognitive.average
old: null
new: 0.5
path: .spaces[0].metrics.cognitive.sum
old: 0.0
new: 5.0
path: .spaces[0].metrics.nargs.average
old: null
new: 0.0
path: .spaces[0].metrics.nom.total
old: 0.0
new: 10.0
path: .spaces[0].metrics.nom.functions
old: 0.0
new: 10.0
path: .spaces[0].metrics.halstead.N2
old: 1.0
new: 210.0
path: .spaces[0].metrics.halstead.estimated_program_length
old: null
new: 943.6574507926928
path: .spaces[0].metrics.halstead.n2
old: 1.0
new: 122.0
path: .spaces[0].metrics.halstead.bugs
old: 0.0
new: 0.6137694150017802
path: .spaces[0].metrics.halstead.n1
old: 0.0
new: 22.0
path: .spaces[0].metrics.halstead.effort
old: 0.0
new: 79011.39811835306
path: .spaces[0].metrics.halstead.vocabulary
old: 1.0
new: 144.0
path: .spaces[0].metrics.halstead.volume
old: 0.0
new: 4172.896350839425
path: .spaces[0].metrics.halstead.time
old: 0.0
new: 4389.522117686281
path: .spaces[0].metrics.halstead.length
old: 1.0
new: 582.0
path: .spaces[0].metrics.halstead.N1
old: 0.0
new: 372.0
path: .spaces[0].metrics.halstead.level
old: null
new: 0.05281385281385281
path: .spaces[0].metrics.halstead.purity_ratio
old: null
new: 1.6214045546266198
path: .spaces[0].metrics.halstead.difficulty
old: 0.0
new: 18.9344262295082
path: .spaces[0].metrics.mi.mi_visual_studio
old: null
new: 24.94316704687133
path: .spaces[0].metrics.mi.mi_sei
old: null
new: -1.0039970801990297
path: .spaces[0].metrics.mi.mi_original
old: null
new: 42.652815650149975
path: .spaces[0].metrics.nexits.sum
old: 0.0
new: 6.0
path: .spaces[0].metrics.nexits.average
old: null
new: 0.6
Code
namespace fuzzer {
using namespace std::chrono;
class Fuzzer {
public:
Fuzzer(UserCallback CB, InputCorpus &Corpus, MutationDispatcher &MD,
FuzzingOptions Options);
~Fuzzer();
void Loop(Vector &CorporaFiles);
void ReadAndExecuteSeedCorpora(Vector &CorporaFiles);
void MinimizeCrashLoop(const Unit &U);
void RereadOutputCorpus(size_t MaxSize);
size_t secondsSinceProcessStartUp() {
return duration_cast(system_clock::now() - ProcessStartTime)
.count();
}
bool TimedOut() {
return Options.MaxTotalTimeSec > 0 &&
secondsSinceProcessStartUp() >
static_cast(Options.MaxTotalTimeSec);
}
size_t execPerSec() {
size_t Seconds = secondsSinceProcessStartUp();
return Seconds ? TotalNumberOfRuns / Seconds : 0;
}
size_t getTotalNumberOfRuns() { return TotalNumberOfRuns; }
static void StaticAlarmCallback();
static void StaticCrashSignalCallback();
static void StaticExitCallback();
static void StaticInterruptCallback();
static void StaticFileSizeExceedCallback();
static void StaticGracefulExitCallback();
int ExecuteCallback(const uint8_t *Data, size_t Size);
bool RunOne(const uint8_t *Data, size_t Size, bool MayDeleteFile = false,
InputInfo *II = nullptr, bool *FoundUniqFeatures = nullptr);
// Merge Corpora[1:] into Corpora[0].
void Merge(const Vector &Corpora);
void CrashResistantMergeInternalStep(const std::string &ControlFilePath);
MutationDispatcher &GetMD() { return MD; }
void PrintFinalStats();
void SetMaxInputLen(size_t MaxInputLen);
void SetMaxMutationLen(size_t MaxMutationLen);
void RssLimitCallback();
bool InFuzzingThread() const { return IsMyThread; }
size_t GetCurrentUnitInFuzzingThead(const uint8_t **Data) const;
void TryDetectingAMemoryLeak(const uint8_t *Data, size_t Size,
bool DuringInitialCorpusExecution);
void HandleMalloc(size_t Size);
static void MaybeExitGracefully();
std::string WriteToOutputCorpus(const Unit &U);
private:
void AlarmCallback();
void CrashCallback();
void ExitCallback();
void CrashOnOverwrittenData();
void InterruptCallback();
void MutateAndTestOne();
void PurgeAllocator();
void ReportNewCoverage(InputInfo *II, const Unit &U);
void PrintPulseAndReportSlowInput(const uint8_t *Data, size_t Size);
void WriteUnitToFileWithPrefix(const Unit &U, const char *Prefix);
void PrintStats(const char *Where, const char *End = "\n", size_t Units = 0,
size_t Features = 0);
void PrintStatusForNewUnit(const Unit &U, const char *Text);
void CheckExitOnSrcPosOrItem();
static void StaticDeathCallback();
void DumpCurrentUnit(const char *Prefix);
void DeathCallback();
void AllocateCurrentUnitData();
uint8_t *CurrentUnitData = nullptr;
std::atomic CurrentUnitSize;
uint8_t BaseSha1[kSHA1NumBytes]; // Checksum of the base unit.
bool GracefulExitRequested = false;
size_t TotalNumberOfRuns = 0;
size_t NumberOfNewUnitsAdded = 0;
size_t LastCorpusUpdateRun = 0;
bool HasMoreMallocsThanFrees = false;
size_t NumberOfLeakDetectionAttempts = 0;
system_clock::time_point LastAllocatorPurgeAttemptTime = system_clock::now();
UserCallback CB;
InputCorpus &Corpus;
MutationDispatcher &MD;
FuzzingOptions Options;
DataFlowTrace DFT;
system_clock::time_point ProcessStartTime = system_clock::now();
system_clock::time_point UnitStartTime, UnitStopTime;
long TimeOfLongestUnitInSeconds = 0;
long EpochOfLastReadOfOutputCorpus = 0;
size_t MaxInputLen = 0;
size_t MaxMutationLen = 0;
size_t TmpMaxMutationLen = 0;
Vector UniqFeatureSetTmp;
// Need to know our own thread.
static thread_local bool IsMyThread;
};
struct ScopedEnableMsanInterceptorChecks {
ScopedEnableMsanInterceptorChecks() {
if (EF->__msan_scoped_enable_interceptor_checks)
EF->__msan_scoped_enable_interceptor_checks();
}
~ScopedEnableMsanInterceptorChecks() {
if (EF->__msan_scoped_disable_interceptor_checks)
EF->__msan_scoped_disable_interceptor_checks();
}
};
struct ScopedDisableMsanInterceptorChecks {
ScopedDisableMsanInterceptorChecks() {
if (EF->__msan_scoped_disable_interceptor_checks)
EF->__msan_scoped_disable_interceptor_checks();
}
~ScopedDisableMsanInterceptorChecks() {
if (EF->__msan_scoped_enable_interceptor_checks)
EF->__msan_scoped_enable_interceptor_checks();
}
};
} // namespace fuzzer