-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch1.diff
More file actions
1100 lines (1066 loc) · 41.3 KB
/
Copy pathpatch1.diff
File metadata and controls
1100 lines (1066 loc) · 41.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/compiler-rt/lib/fuzzer/FuzzerCorpus.h b/compiler-rt/lib/fuzzer/FuzzerCorpus.h
index 6a95ef3a8e64..9b9139b98eb0 100644
--- a/compiler-rt/lib/fuzzer/FuzzerCorpus.h
+++ b/compiler-rt/lib/fuzzer/FuzzerCorpus.h
@@ -21,6 +21,7 @@
#include <numeric>
#include <random>
#include <unordered_set>
+#include <unordered_map>
namespace fuzzer {
@@ -38,12 +39,103 @@ struct InputInfo {
bool HasFocusFunction = false;
Vector<uint32_t> UniqFeatureSet;
Vector<uint8_t> DataFlowTraceForFocusFunction;
+ // size_t NumOfMutationAttempts = 0;
+ size_t SeedID=0;
+ // Power schedule.
+ bool NeedsEnergyUpdate = false;
+ double Energy = 0.0;
+ size_t SumIncidence = 0;
+ Vector<std::pair<uint32_t, uint16_t>> FeatureFreqs;
+ // Delete feature Idx and its frequency from FeatureFreqs.
+ bool DeleteFeatureFreq(uint32_t Idx) {
+ if (FeatureFreqs.empty())
+ return false;
+
+ // Binary search over local feature frequencies sorted by index.
+ auto Lower = std::lower_bound(FeatureFreqs.begin(), FeatureFreqs.end(),
+ std::pair<uint32_t, uint16_t>(Idx, 0));
+
+ if (Lower != FeatureFreqs.end() && Lower->first == Idx) {
+ FeatureFreqs.erase(Lower);
+ return true;
+ }
+ return false;
+ }
+
+ // Assign more energy to a high-entropy seed, i.e., that reveals more
+ // information about the globally rare features in the neighborhood
+ // of the seed. Since we do not know the entropy of a seed that has
+ // never been executed we assign fresh seeds maximum entropy and
+ // let II->Energy approach the true entropy from above.
+ void UpdateEnergy(size_t GlobalNumberOfFeatures) {
+ Energy = 0.0;
+ SumIncidence = 0;
+
+ // Apply add-one smoothing to locally discovered features.
+ for (auto F : FeatureFreqs) {
+ size_t LocalIncidence = F.second + 1;
+ Energy -= LocalIncidence * logl(LocalIncidence);
+ SumIncidence += LocalIncidence;
+ }
+
+ // Apply add-one smoothing to locally undiscovered features.
+ // PreciseEnergy -= 0; // since logl(1.0) == 0)
+ SumIncidence += (GlobalNumberOfFeatures - FeatureFreqs.size());
+
+ // Add a single locally abundant feature apply add-one smoothing.
+ size_t AbdIncidence = NumExecutedMutations + 1;
+ Energy -= AbdIncidence * logl(AbdIncidence);
+ SumIncidence += AbdIncidence;
+
+ // Normalize.
+ if (SumIncidence != 0)
+ Energy = (Energy / SumIncidence) + logl(SumIncidence);
+ }
+
+ // Increment the frequency of the feature Idx.
+ void UpdateFeatureFrequency(uint32_t Idx) {
+ NeedsEnergyUpdate = true;
+
+ // The local feature frequencies is an ordered vector of pairs.
+ // If there are no local feature frequencies, push_back preserves order.
+ // Set the feature frequency for feature Idx32 to 1.
+ if (FeatureFreqs.empty()) {
+ FeatureFreqs.push_back(std::pair<uint32_t, uint16_t>(Idx, 1));
+ return;
+ }
+
+ // Binary search over local feature frequencies sorted by index.
+ auto Lower = std::lower_bound(FeatureFreqs.begin(), FeatureFreqs.end(),
+ std::pair<uint32_t, uint16_t>(Idx, 0));
+
+ // If feature Idx32 already exists, increment its frequency.
+ // Otherwise, insert a new pair right after the next lower index.
+ if (Lower != FeatureFreqs.end() && Lower->first == Idx) {
+ Lower->second++;
+ } else {
+ FeatureFreqs.insert(Lower, std::pair<uint32_t, uint16_t>(Idx, 1));
+ }
+ }
+};
+
+struct EntropicOptions {
+ bool Enabled;
+ size_t NumberOfRarestFeatures;
+ size_t FeatureFrequencyThreshold;
};
class InputCorpus {
- static const size_t kFeatureSetSize = 1 << 21;
- public:
- InputCorpus(const std::string &OutputCorpus) : OutputCorpus(OutputCorpus) {
+ static const uint32_t kFeatureSetSize = 1 << 21;
+ static const uint8_t kMaxMutationFactor = 20;
+ static const size_t kSparseEnergyUpdates = 100;
+
+ size_t NumExecutedMutations = 0;
+
+ EntropicOptions Entropic;
+
+public:
+ InputCorpus(const std::string &OutputCorpus, EntropicOptions Entropic)
+ : Entropic(Entropic), OutputCorpus(OutputCorpus) {
memset(InputSizesPerFeature, 0, sizeof(InputSizesPerFeature));
memset(SmallestElementPerFeature, 0, sizeof(SmallestElementPerFeature));
}
@@ -71,6 +163,187 @@ class InputCorpus {
return Res;
}
+ size_t Nextprint = 100;
+ size_t Measurements = 0;
+ uint8_t SeedsCounter = 0; // When counter reaches 10 (paths discovered), fork fuzzer
+ uint8_t ForksCounter = 0; // fork counter
+ size_t MutationsInFork = 0; // In the fork, number of mutations it took to reach next path
+ size_t MaxMutationsInFork = 0; // try max fork muts
+ size_t AvgMutationsInFork = 0; // try average fork muts
+ bool ForkSuccessful = false; // whether fork was successful
+ const uint8_t SeedsLimit = 1; // number of seeds after which to fork
+ const uint8_t ForkLimit = 10; // number of forks to perform
+ bool ForkMode = false;
+ // std::unordered_map<size_t,size_t> SeedTrialMap;
+ std::unordered_map<size_t,size_t> TmpSeedTrialMap;
+ size_t NewFeaturesDuringMeasurement = 0;
+ Vector<size_t> GlobalFailsVector; // fails until cur seed, only choose attempted seeds
+ size_t TrialsToSuccess=0;
+ size_t GlobalSeedID=0;
+ size_t GlobalFeats = 0;
+ size_t GlobalLLaplace =0;
+ size_t GlobalLGT=0;
+ size_t GlobalMaxForkMutations=0; // max mutations in fork
+ size_t GlobalAvgForkMutations=0; // avg of mutations in fork
+ size_t GlobalExecRate=0; // record exec rate every few successful mutations
+ uint8_t SetNewFeaturesDuringMeasurement = 0;
+
+ void CalcEst() { // call this every time we append to GlobalFails vector
+ long double laplace = 0;
+ long double local_gt = 0;
+
+ for (size_t i = 0; i < Inputs.size(); i++) {
+ auto &II = *Inputs[i];
+ DistributionNeedsUpdate = true;
+ Random Rand(0);
+ UpdateCorpusDistribution(Rand);
+ double weight = CorpusDistribution.densities()[i];
+ if (II.NumExecutedMutations == 0) {
+ laplace += weight;
+ local_gt += weight;
+ } else {
+ size_t localSingletonsForII = 0;
+ for (auto entry : II.FeatureFreqs) {
+ if (entry.second == 1)
+ localSingletonsForII ++;
+ }
+ if (localSingletonsForII > 0)
+ local_gt += weight * (localSingletonsForII / (long double) II.NumExecutedMutations);
+ else
+ local_gt += weight / (long double) (II.NumExecutedMutations + 2);
+
+ size_t globalSingletonsForII = 0;
+ for (uint32_t Idx : RareFeatures) {
+ if (GlobalFeatureFreqs[Idx] == 1) {
+ if (II.FeatureFreqs.empty()) continue;
+ // Binary search over local feature frequencies sorted by index.
+ auto Lower = std::lower_bound(II.FeatureFreqs.begin(), II.FeatureFreqs.end(),
+ std::pair<uint32_t, uint16_t>(Idx, 0));
+ if (Lower != II.FeatureFreqs.end() && Lower->first == Idx) {
+ globalSingletonsForII++;
+ }
+ }
+ }
+ if (globalSingletonsForII > 0)
+ laplace += weight * (globalSingletonsForII / (long double) II.NumExecutedMutations);
+ else
+ laplace += weight / (long double) (II.NumExecutedMutations + 2);
+ }
+ }
+ laplace *= NumExecutedMutations;
+ local_gt *= NumExecutedMutations;
+ size_t Laplace = (size_t)std::round(laplace);
+ size_t LocalGt = (size_t)std::round(local_gt);
+ GlobalLLaplace = Laplace;
+ GlobalLGT = LocalGt;
+ }
+
+ void IncrementNumExecutedMutations() {
+ // SetNewFeaturesDuringMeasurement = 0;
+ // if (Measurements > 0) { // blackbox measurement, never reached
+ // Measurements--;
+ // UnsuccMutations = 0; // don't want to record anymore
+ // if (Measurements == 0) {
+ // PrintCSV();
+ // }
+ // else { // greybox measurement
+ NumExecutedMutations++;
+ if (NumExecutedMutations == Nextprint) {
+ // Measurements = NumExecutedMutations; //stopping blackbox
+ // if(UnsuccMutations != 0) { // at the end of GB, if there any left
+ // GlobalTrialsVector.push_back(UnsuccMutations);
+ // GlobalFeatsVector.push_back(0);
+ // CalcEst();
+ // UnsuccMutations = 0; // reset fails after this success
+ // }
+ NewFeaturesDuringMeasurement = 0;
+ memset(BlackboxFeatureFreqs, 0, sizeof BlackboxFeatureFreqs);
+ BlackboxSingletons.clear();
+ Nextprint *= 2;
+ // PrintCSV();
+ }
+ }
+
+ void PrintCSV() {
+ // Find singletons, etc.
+ // size_t Xtons[4] = {};
+ // size_t Vtons[4] = {};
+ // for (uint32_t Idx : RareFeatures) {
+ // for (uint8_t i = 0; i < 4; i++) {
+ // if (GlobalFeatureFreqs[Idx] == i + 1)
+ // Xtons[i]++;
+ // if (ValentinFeatureFreqs[Idx] == i + 1)
+ // Vtons[i]++;
+ // }
+ // }
+ // long double laplace = 0;
+ // long double local_gt = 0;
+ // for (size_t i = 0; i < Inputs.size(); i++) {
+ // auto &II = *Inputs[i];
+ // DistributionNeedsUpdate = true;
+ // Random Rand(0);
+ // UpdateCorpusDistribution(Rand);
+ // double weight = CorpusDistribution.densities()[i];
+ // if (II.NumExecutedMutations == 0) {
+ // laplace += weight;
+ // local_gt += weight;
+ // } else {
+ // size_t localSingletonsForII = 0;
+ // for (auto entry : II.FeatureFreqs) {
+ // if (entry.second == 1)
+ // localSingletonsForII ++;
+ // }
+ // if (localSingletonsForII > 0)
+ // local_gt += weight * (localSingletonsForII / (long double) II.NumExecutedMutations);
+ // else
+ // local_gt += weight / (long double) (II.NumExecutedMutations + 2);
+ // size_t globalSingletonsForII = 0;
+ // for (uint32_t Idx : RareFeatures) {
+ // if (GlobalFeatureFreqs[Idx] == 1) {
+ // if (II.FeatureFreqs.empty()) continue;
+ // // Binary search over local feature frequencies sorted by index.
+ // auto Lower = std::lower_bound(II.FeatureFreqs.begin(), II.FeatureFreqs.end(),
+ // std::pair<uint32_t, uint16_t>(Idx, 0));
+ // if (Lower != II.FeatureFreqs.end() && Lower->first == Idx) {
+ // globalSingletonsForII++;
+ // }
+ // }
+ // }
+ // if (globalSingletonsForII > 0)
+ // laplace += weight * (globalSingletonsForII / (long double) II.NumExecutedMutations);
+ // else
+ // laplace += weight / (long double) (II.NumExecutedMutations + 2);
+ // }
+ // }
+ // laplace *= NumExecutedMutations;
+ // local_gt *= NumExecutedMutations;
+ // double reset10 = NumExecutedMutations * Reset10F1 / (double) (NumExecutedMutations - Reset10Time);
+ // double reset1 = NumExecutedMutations * Reset1F1 / (double) (NumExecutedMutations - Reset1Time);
+ // size_t Laplace = (size_t)std::round(laplace);
+ // size_t LocalGt = (size_t)std::round(local_gt);
+ // size_t Reset10 = (size_t)std::round(reset10);
+ // size_t Reset1 = (size_t)std::round(reset1);
+ // Printf("__STATS__ %zd,%zd,%zd %zd, %zd, %zd, %zd, %zd, %zd,%zd,%zd,%zd,%zd,%zd,%zd,%zd, %zd\n",
+ // NumExecutedMutations, NewFeaturesDuringMeasurement,
+ // Laplace, LocalGt, Reset1, Reset10, BlackboxSingletons.size(),
+ // Xtons[0], Xtons[1], Xtons[2], Xtons[3],
+ // Vtons[0], Vtons[1], Vtons[2], Vtons[3], MaxInputsReqOverall);
+
+ Printf("__SUCCS__ %zd, %zd\n", NumExecutedMutations,TrialsToSuccess);
+ Printf("__FAILS__ %zd, ", NumExecutedMutations);
+ for(auto& x: GlobalFailsVector){
+ Printf("%zd, ", x);
+ }
+ Printf("\n");
+ Printf("__FEATS__ %zd, %zd\n", NumExecutedMutations,GlobalFeats);
+ Printf("__LLAPL__ %zd, %zd\n", NumExecutedMutations,GlobalLLaplace);
+ Printf("__LGDTU__ %zd, %zd\n", NumExecutedMutations,GlobalLGT);
+ Printf("__MXFRK__ %zd, %zd\n", NumExecutedMutations, GlobalMaxForkMutations);
+ Printf("__AVFRK__ %zd, %zd\n", NumExecutedMutations, GlobalAvgForkMutations);
+ Printf("__RATES__ %zd, %zd\n", NumExecutedMutations, GlobalExecRate);
+ GlobalFailsVector.clear();
+ }
+
size_t NumInputsThatTouchFocusFunction() {
return std::count_if(Inputs.begin(), Inputs.end(), [](const InputInfo *II) {
return II->HasFocusFunction;
@@ -83,12 +356,19 @@ class InputCorpus {
});
}
+ size_t Reset10Time = 0;
+ size_t Reset1Time = 0;
+ size_t Reset10F1 = 0;
+ size_t Reset1F1 = 0;
bool empty() const { return Inputs.empty(); }
const Unit &operator[] (size_t Idx) const { return Inputs[Idx]->U; }
InputInfo *AddToCorpus(const Unit &U, size_t NumFeatures, bool MayDeleteFile,
bool HasFocusFunction,
const Vector<uint32_t> &FeatureSet,
const DataFlowTrace &DFT, const InputInfo *BaseII) {
+
+ if (Measurements > 0) return NULL;
+
assert(!U.empty());
if (FeatureDebug)
Printf("ADD_TO_CORPUS %zd NF %zd\n", Inputs.size(), NumFeatures);
@@ -99,6 +379,11 @@ class InputCorpus {
II.MayDeleteFile = MayDeleteFile;
II.UniqFeatureSet = FeatureSet;
II.HasFocusFunction = HasFocusFunction;
+ II.SeedID = GlobalSeedID++;
+ // Assign maximal energy to the new seed.
+ II.Energy = RareFeatures.empty() ? 1.0 : log(RareFeatures.size());
+ II.SumIncidence = RareFeatures.size();
+ II.NeedsEnergyUpdate = false;
std::sort(II.UniqFeatureSet.begin(), II.UniqFeatureSet.end());
ComputeSHA1(U.data(), U.size(), II.Sha1);
auto Sha1Str = Sha1ToString(II.Sha1);
@@ -111,8 +396,41 @@ class InputCorpus {
// But if we don't, we'll use the DFT of its base input.
if (II.DataFlowTraceForFocusFunction.empty() && BaseII)
II.DataFlowTraceForFocusFunction = BaseII->DataFlowTraceForFocusFunction;
- UpdateCorpusDistribution();
+ DistributionNeedsUpdate = true;
PrintCorpus();
+
+ if (!(std::rand() % 10)) {
+ Reset10Time = NumExecutedMutations;
+ Reset10F1 = 0;
+ uint64_t *y = (uint64_t*)Reset10FeatureFreqs;
+ uint32_t i = kFeatureSetSize / 4;
+ while (i--) {
+ if (*y) {
+ uint16_t* z = (uint16_t*) y;
+ if (z[0] == 1) Reset10F1 ++;
+ if (z[1] == 1) Reset10F1 ++;
+ if (z[2] == 1) Reset10F1 ++;
+ if (z[3] == 1) Reset10F1 ++;
+ }
+ y++;
+ }
+ memset(Reset10FeatureFreqs, 0, sizeof Reset10FeatureFreqs);
+ }
+ Reset1Time = NumExecutedMutations;
+ Reset1F1 = 0;
+ uint64_t *y = (uint64_t*)Reset1FeatureFreqs;
+ uint32_t i = kFeatureSetSize / 4;
+ while (i--) {
+ if (*y) {
+ uint16_t* z = (uint16_t*) y;
+ if (z[0] == 1) Reset1F1 ++;
+ if (z[1] == 1) Reset1F1 ++;
+ if (z[2] == 1) Reset1F1 ++;
+ if (z[3] == 1) Reset1F1 ++;
+ }
+ y++;
+ }
+ memset(Reset1FeatureFreqs, 0, sizeof Reset1FeatureFreqs);
// ValidateFeatureSet();
return &II;
}
@@ -155,6 +473,7 @@ class InputCorpus {
}
void Replace(InputInfo *II, const Unit &U) {
+ if (Measurements > 0) return;
assert(II->U.size() > U.size());
Hashes.erase(Sha1ToString(II->Sha1));
DeleteFile(*II);
@@ -162,7 +481,7 @@ class InputCorpus {
Hashes.insert(Sha1ToString(II->Sha1));
II->U = U;
II->Reduced = true;
- UpdateCorpusDistribution();
+ DistributionNeedsUpdate = true;
}
bool HasUnit(const Unit &U) { return Hashes.count(Hash(U)); }
@@ -175,6 +494,7 @@ class InputCorpus {
// Returns an index of random unit from the corpus to mutate.
size_t ChooseUnitIdxToMutate(Random &Rand) {
+ UpdateCorpusDistribution(Rand);
size_t Idx = static_cast<size_t>(CorpusDistribution(Rand));
assert(Idx < Inputs.size());
return Idx;
@@ -202,23 +522,87 @@ class InputCorpus {
}
void DeleteFile(const InputInfo &II) {
- if (!OutputCorpus.empty() && II.MayDeleteFile)
+ if (!OutputCorpus.empty() && II.MayDeleteFile) {
RemoveFile(DirPlusFile(OutputCorpus, Sha1ToString(II.Sha1)));
+ }
}
void DeleteInput(size_t Idx) {
InputInfo &II = *Inputs[Idx];
+ // SeedTrialMap.erase(II.SeedID);
DeleteFile(II);
Unit().swap(II.U);
+ II.Energy = 0.0;
+ II.NeedsEnergyUpdate = false;
+ DistributionNeedsUpdate = true;
if (FeatureDebug)
Printf("EVICTED %zd\n", Idx);
}
+ void AddRareFeature(uint32_t Idx) {
+ // Maintain *at least* TopXRarestFeatures many rare features
+ // and all features with a frequency below ConsideredRare.
+ // Remove all other features.
+ while (RareFeatures.size() > Entropic.NumberOfRarestFeatures &&
+ FreqOfMostAbundantRareFeature > Entropic.FeatureFrequencyThreshold) {
+
+ // Find most and second most abbundant feature.
+ uint32_t MostAbundantRareFeatureIndices[2] = {RareFeatures[0],
+ RareFeatures[0]};
+ size_t Delete = 0;
+ for (size_t i = 0; i < RareFeatures.size(); i++) {
+ uint32_t Idx2 = RareFeatures[i];
+ if (GlobalFeatureFreqs[Idx2] >=
+ GlobalFeatureFreqs[MostAbundantRareFeatureIndices[0]]) {
+ MostAbundantRareFeatureIndices[1] = MostAbundantRareFeatureIndices[0];
+ MostAbundantRareFeatureIndices[0] = Idx2;
+ Delete = i;
+ }
+ }
+
+ // Remove most abundant rare feature.
+ RareFeatures[Delete] = RareFeatures.back();
+ RareFeatures.pop_back();
+
+ for (auto II : Inputs) {
+ if (II->DeleteFeatureFreq(MostAbundantRareFeatureIndices[0]))
+ II->NeedsEnergyUpdate = true;
+ }
+
+ // Set 2nd most abundant as the new most abundant feature count.
+ FreqOfMostAbundantRareFeature =
+ GlobalFeatureFreqs[MostAbundantRareFeatureIndices[1]];
+ }
+
+ // Add rare feature, handle collisions, and update energy.
+ RareFeatures.push_back(Idx);
+ GlobalFeatureFreqs[Idx] = 0;
+ for (auto II : Inputs) {
+ II->DeleteFeatureFreq(Idx);
+
+ // Apply add-one smoothing to this locally undiscovered feature.
+ // Zero energy seeds will never be fuzzed and remain zero energy.
+ if (II->Energy > 0.0) {
+ II->SumIncidence += 1;
+ II->Energy += logl(II->SumIncidence) / II->SumIncidence;
+ }
+ }
+
+ DistributionNeedsUpdate = true;
+ }
+
bool AddFeature(size_t Idx, uint32_t NewSize, bool Shrink) {
+
+ // if (Measurements > 0) return false;
assert(NewSize);
Idx = Idx % kFeatureSetSize;
uint32_t OldSize = GetFeature(Idx);
if (OldSize == 0 || (Shrink && OldSize > NewSize)) {
+ if (ForkMode) {
+ ForkSuccessful = true;
+ return false;
+ }
+
if (OldSize > 0) {
size_t OldIdx = SmallestElementPerFeature[Idx];
InputInfo &II = *Inputs[OldIdx];
@@ -228,6 +612,8 @@ class InputCorpus {
DeleteInput(OldIdx);
} else {
NumAddedFeatures++;
+ //if (Entropic.Enabled)
+ AddRareFeature((uint32_t)Idx);
}
NumUpdatedFeatures++;
if (FeatureDebug)
@@ -239,8 +625,58 @@ class InputCorpus {
return false;
}
+ // Increment frequency of feature Idx globally and locally.
+ void UpdateFeatureFrequency(InputInfo *II, size_t Idx) {
+ uint32_t Idx32 = Idx % kFeatureSetSize;
+
+ if (BlackboxFeatureFreqs[Idx32] < 2) {
+ if (BlackboxFeatureFreqs[Idx32] == 0) {
+ BlackboxSingletons.push_back(Idx32);
+ BlackboxFeatureFreqs[Idx32] = 1;
+ } else {
+ BlackboxSingletons.erase(std::remove(BlackboxSingletons.begin(), BlackboxSingletons.end(), Idx32), BlackboxSingletons.end());
+ BlackboxFeatureFreqs[Idx32] = 2;
+ }
+ }
+
+ // Saturated increment.
+ if (GlobalFeatureFreqs[Idx32] == 0xFFFF)
+ return;
+ if (ForkMode) return;
+ if (Measurements > 0) {
+ if (GlobalFeatureFreqs[Idx32] == 0 && !SetNewFeaturesDuringMeasurement) {
+ NewFeaturesDuringMeasurement++;
+ SetNewFeaturesDuringMeasurement = 1;
+ }
+ return;
+ }
+
+ uint16_t Freq = GlobalFeatureFreqs[Idx32]++;
+ Reset10FeatureFreqs[Idx32]++;
+ Reset1FeatureFreqs[Idx32]++;
+
+ // TODO DELME Only increment if II does not have this in its UniqFeatureSet
+ if (!Entropic.Enabled && (!II || std::find(II->UniqFeatureSet.begin(), II->UniqFeatureSet.end(), Idx32) == II->UniqFeatureSet.end()))
+ ValentinFeatureFreqs[Idx32]++;
+
+ // Skip if abundant.
+ if (Freq > FreqOfMostAbundantRareFeature ||
+ std::find(RareFeatures.begin(), RareFeatures.end(), Idx32) ==
+ RareFeatures.end())
+ return;
+
+ // Update global frequencies.
+ if (Freq == FreqOfMostAbundantRareFeature)
+ FreqOfMostAbundantRareFeature++;
+
+ // Update local frequencies.
+ if (II)
+ II->UpdateFeatureFrequency(Idx32);
+ }
+
size_t NumFeatures() const { return NumAddedFeatures; }
size_t NumFeatureUpdates() const { return NumUpdatedFeatures; }
+ size_t NumExMuts() const { return NumExecutedMutations; }
private:
@@ -265,19 +701,60 @@ private:
// Updates the probability distribution for the units in the corpus.
// Must be called whenever the corpus or unit weights are changed.
//
- // Hypothesis: units added to the corpus last are more interesting.
- //
- // Hypothesis: inputs with infrequent features are more interesting.
- void UpdateCorpusDistribution() {
+ // Hypothesis: inputs that maximize information about globally rare features
+ // are interesting.
+ void UpdateCorpusDistribution(Random &Rand) {
+ // Skip update if no seeds or rare features were added/deleted.
+ // Sparse updates for local change of feature frequencies,
+ // i.e., randomly do not skip.
+ if (!DistributionNeedsUpdate &&
+ (!Entropic.Enabled || Rand(kSparseEnergyUpdates)))
+ return;
+
+ DistributionNeedsUpdate = false;
+
size_t N = Inputs.size();
assert(N);
Intervals.resize(N + 1);
Weights.resize(N);
std::iota(Intervals.begin(), Intervals.end(), 0);
- for (size_t i = 0; i < N; i++)
- Weights[i] = Inputs[i]->NumFeatures
- ? (i + 1) * (Inputs[i]->HasFocusFunction ? 1000 : 1)
- : 0.;
+
+ bool VanillaSchedule = true;
+ if (Entropic.Enabled) {
+ for (auto II : Inputs) {
+ if (II->NeedsEnergyUpdate && II->Energy != 0.0) {
+ II->NeedsEnergyUpdate = false;
+ II->UpdateEnergy(RareFeatures.size());
+ }
+ }
+
+ for (size_t i = 0; i < N; i++) {
+
+ if (Inputs[i]->NumFeatures == 0) {
+ // If the seed doesn't represent any features, assign zero energy.
+ Weights[i] = 0.;
+ } else if (Inputs[i]->NumExecutedMutations / kMaxMutationFactor >
+ NumExecutedMutations / Inputs.size()) {
+ // If the seed was fuzzed a lot more than average, assign zero energy.
+ Weights[i] = 0.;
+ } else {
+ // Otherwise, simply assign the computed energy.
+ Weights[i] = Inputs[i]->Energy;
+ }
+
+ // If energy for all seeds is zero, fall back to vanilla schedule.
+ if (Weights[i] > 0.0)
+ VanillaSchedule = false;
+ }
+ }
+
+ if (VanillaSchedule) {
+ for (size_t i = 0; i < N; i++)
+ Weights[i] = Inputs[i]->NumFeatures
+ ? (i + 1) * (Inputs[i]->HasFocusFunction ? 1000 : 1)
+ : 0.;
+ }
+
if (FeatureDebug) {
for (size_t i = 0; i < N; i++)
Printf("%zd ", Inputs[i]->NumFeatures);
@@ -302,6 +779,16 @@ private:
uint32_t InputSizesPerFeature[kFeatureSetSize];
uint32_t SmallestElementPerFeature[kFeatureSetSize];
+ bool DistributionNeedsUpdate = true;
+ uint16_t FreqOfMostAbundantRareFeature = 0;
+ uint16_t GlobalFeatureFreqs[kFeatureSetSize] = {};
+ uint16_t ValentinFeatureFreqs[kFeatureSetSize] = {};
+ uint16_t BlackboxFeatureFreqs[kFeatureSetSize] = {};
+ uint16_t Reset1FeatureFreqs[kFeatureSetSize] = {};
+ uint16_t Reset10FeatureFreqs[kFeatureSetSize] = {};
+ Vector<uint32_t> RareFeatures;
+ Vector<uint32_t> BlackboxSingletons;
+
std::string OutputCorpus;
};
diff --git a/compiler-rt/lib/fuzzer/FuzzerDriver.cpp b/compiler-rt/lib/fuzzer/FuzzerDriver.cpp
index 0d4e468a674b..1a0b2580c5b7 100644
--- a/compiler-rt/lib/fuzzer/FuzzerDriver.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerDriver.cpp
@@ -708,6 +708,26 @@ int FuzzerDriver(int *argc, char ***argv, UserCallback Callback) {
Options.CollectDataFlow = Flags.collect_data_flow;
if (Flags.stop_file)
Options.StopFile = Flags.stop_file;
+ Options.Entropic = Flags.entropic;
+ Options.EntropicFeatureFrequencyThreshold =
+ (size_t)Flags.entropic_feature_frequency_threshold;
+ Options.EntropicNumberOfRarestFeatures =
+ (size_t)Flags.entropic_number_of_rarest_features;
+ if (Options.Entropic) {
+ if (!Options.FocusFunction.empty()) {
+ Printf("ERROR: The parameters `--entropic` and `--focus_function` cannot "
+ "be used together.\n");
+ exit(1);
+ }
+ Printf("INFO: Running with entropic power schedule (0x%X, %d).\n",
+ Options.EntropicFeatureFrequencyThreshold,
+ Options.EntropicNumberOfRarestFeatures);
+ }
+ struct EntropicOptions Entropic;
+ Entropic.Enabled = Options.Entropic;
+ Entropic.FeatureFrequencyThreshold =
+ Options.EntropicFeatureFrequencyThreshold;
+ Entropic.NumberOfRarestFeatures = Options.EntropicNumberOfRarestFeatures;
unsigned Seed = Flags.seed;
// Initialize Seed.
@@ -728,7 +748,7 @@ int FuzzerDriver(int *argc, char ***argv, UserCallback Callback) {
Random Rand(Seed);
auto *MD = new MutationDispatcher(Rand, Options);
- auto *Corpus = new InputCorpus(Options.OutputCorpus);
+ auto *Corpus = new InputCorpus(Options.OutputCorpus, Entropic);
auto *F = new Fuzzer(Callback, *Corpus, *MD, Options);
for (auto &U: Dictionary)
diff --git a/compiler-rt/lib/fuzzer/FuzzerFlags.def b/compiler-rt/lib/fuzzer/FuzzerFlags.def
index a67415743032..e4c99772c88a 100644
--- a/compiler-rt/lib/fuzzer/FuzzerFlags.def
+++ b/compiler-rt/lib/fuzzer/FuzzerFlags.def
@@ -153,6 +153,14 @@ FUZZER_FLAG_STRING(focus_function, "Experimental. "
"Fuzzing will focus on inputs that trigger calls to this function. "
"If -focus_function=auto and -data_flow_trace is used, libFuzzer "
"will choose the focus functions automatically.")
+FUZZER_FLAG_INT(entropic, 0, "Experimental. Enables entropic power schedule.")
+FUZZER_FLAG_INT(entropic_feature_frequency_threshold, 0xFF, "Experimental. If "
+ "entropic is enabled, all features which are observed less often than "
+ "the specified value are considered as rare.")
+FUZZER_FLAG_INT(entropic_number_of_rarest_features, 100, "Experimental. If "
+ "entropic is enabled, we keep track of the frequencies only for the "
+ "Top-X least abundant features (union features that are considered as "
+ "rare).")
FUZZER_FLAG_INT(analyze_dict, 0, "Experimental")
FUZZER_DEPRECATED_FLAG(use_clang_coverage)
diff --git a/compiler-rt/lib/fuzzer/FuzzerFork.cpp b/compiler-rt/lib/fuzzer/FuzzerFork.cpp
index d9e6b79443e0..df439efd056b 100644
--- a/compiler-rt/lib/fuzzer/FuzzerFork.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerFork.cpp
@@ -21,6 +21,8 @@
#include <chrono>
#include <condition_variable>
#include <fstream>
+#include <sys/stat.h>
+#include <iostream>
#include <memory>
#include <mutex>
#include <queue>
@@ -33,6 +35,7 @@ struct Stats {
size_t number_of_executed_units = 0;
size_t peak_rss_mb = 0;
size_t average_exec_per_sec = 0;
+ std::string data = "";
};
static Stats ParseFinalStatsFromLog(const std::string &LogPath) {
@@ -49,7 +52,12 @@ static Stats ParseFinalStatsFromLog(const std::string &LogPath) {
{nullptr, nullptr},
};
while (std::getline(In, Line, '\n')) {
+ printf("%s\n", Line.c_str());
if (Line.find("stat::") != 0) continue;
+ if (Line.find("stat::csv:") == 0) {
+ Res.data = Line.substr(11);
+ continue;
+ }
std::istringstream ISS(Line);
std::string Name;
size_t Val;
@@ -70,6 +78,8 @@ struct FuzzJob {
std::string SeedListPath;
std::string CFPath;
size_t JobId;
+ bool Executing = false;
+ Vector<std::string> CopiedSeeds;
int DftTimeInSeconds = 0;
@@ -124,7 +134,6 @@ struct GlobalEnv {
Cmd.addFlag("reload", "0"); // working in an isolated dir, no reload.
Cmd.addFlag("print_final_stats", "1");
Cmd.addFlag("print_funcs", "0"); // no need to spend time symbolizing.
- Cmd.addFlag("max_total_time", std::to_string(std::min((size_t)300, JobId)));
Cmd.addFlag("stop_file", StopFile());
if (!DataFlowBinary.empty()) {
Cmd.addFlag("data_flow_trace", DFTDir);
@@ -133,11 +142,10 @@ struct GlobalEnv {
}
auto Job = new FuzzJob;
std::string Seeds;
- if (size_t CorpusSubsetSize =
- std::min(Files.size(), (size_t)sqrt(Files.size() + 2))) {
+ if (size_t CorpusSubsetSize = Files.size()) {
auto Time1 = std::chrono::system_clock::now();
for (size_t i = 0; i < CorpusSubsetSize; i++) {
- auto &SF = Files[Rand->SkewTowardsLast(Files.size())];
+ auto &SF = Files[i];
Seeds += (Seeds.empty() ? "" : ",") + SF;
CollectDFT(SF);
}
@@ -206,18 +214,28 @@ struct GlobalEnv {
NumRuns, Cov.size(), Features.size(), Files.size(),
Stats.average_exec_per_sec, NumOOMs, NumTimeouts, NumCrashes,
secondsSinceProcessStartUp(), Job->JobId, Job->DftTimeInSeconds);
-
+ Printf("%s\n", Stats.data.c_str());
if (MergeCandidates.empty()) return;
Vector<std::string> FilesToAdd;
Set<uint32_t> NewFeatures, NewCov;
CrashResistantMerge(Args, {}, MergeCandidates, &FilesToAdd, Features,
&NewFeatures, Cov, &NewCov, Job->CFPath, false);
+ RemoveFile(Job->CFPath);
+
for (auto &Path : FilesToAdd) {
- auto U = FileToVector(Path);
- auto NewPath = DirPlusFile(MainCorpusDir, Hash(U));
- WriteToFile(U, NewPath);
- Files.push_back(NewPath);
+ // Only merge files that have not been merged already.
+ if (std::find(Job->CopiedSeeds.begin(), Job->CopiedSeeds.end(), Path) == Job->CopiedSeeds.end()) {
+ // NOT THREAD SAFE: Fast check whether file still exists.
+ struct stat buffer;
+ if (stat (Path.c_str(), &buffer) == 0) {
+ auto U = FileToVector(Path);
+ auto NewPath = DirPlusFile(MainCorpusDir, Hash(U));
+ WriteToFile(U, NewPath);
+ Files.push_back(NewPath);
+ Job->CopiedSeeds.push_back(Path);
+ }
+ }
}
Features.insert(NewFeatures.begin(), NewFeatures.end());
Cov.insert(NewCov.begin(), NewCov.end());
@@ -271,10 +289,20 @@ struct JobQueue {
}
};
-void WorkerThread(JobQueue *FuzzQ, JobQueue *MergeQ) {
+void WorkerThread(GlobalEnv *Env, JobQueue *FuzzQ, JobQueue *MergeQ) {
while (auto Job = FuzzQ->Pop()) {
// Printf("WorkerThread: job %p\n", Job);
+ Job->Executing = true;
+ int Sleep_ms = 300000;
+ std::thread([=]() {
+ std::this_thread::sleep_for(std::chrono::milliseconds(Sleep_ms));
+ while (Job->Executing) {
+ Env->RunOneMergeJob(Job);
+ std::this_thread::sleep_for(std::chrono::milliseconds(Sleep_ms));
+ }
+ }).detach();
Job->ExitCode = ExecuteCommand(Job->Cmd);
+ Job->Executing = false;
MergeQ->Push(Job);
}
}
@@ -331,7 +359,7 @@ void FuzzWithFork(Random &Rand, const FuzzingOptions &Options,
size_t JobId = 1;
Vector<std::thread> Threads;
for (int t = 0; t < NumJobs; t++) {
- Threads.push_back(std::thread(WorkerThread, &FuzzQ, &MergeQ));
+ Threads.push_back(std::thread(WorkerThread, &Env, &FuzzQ, &MergeQ));
FuzzQ.Push(Env.CreateNewJob(JobId++));
}
diff --git a/compiler-rt/lib/fuzzer/FuzzerLoop.cpp b/compiler-rt/lib/fuzzer/FuzzerLoop.cpp
index 273c62919e89..ce68459ba92f 100644
--- a/compiler-rt/lib/fuzzer/FuzzerLoop.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerLoop.cpp
@@ -324,6 +324,10 @@ void Fuzzer::PrintStats(const char *Where, const char *End, size_t Units,
size_t ExecPerSec = execPerSec();
if (!Options.Verbosity)
return;
+ if (!Options.Entropic) {
+ return;
+ }
+ return; // hiding logs
Printf("#%zd\t%s", TotalNumberOfRuns, Where);
if (size_t N = TPC.GetTotalPCCoverage())
Printf(" cov: %zd", N);
@@ -350,6 +354,7 @@ void Fuzzer::PrintStats(const char *Where, const char *End, size_t Units,
Printf(" exec/s: %zd", ExecPerSec);
Printf(" rss: %zdMb", GetPeakRSSMb());
Printf("%s", End);
+
}
void Fuzzer::PrintFinalStats() {
@@ -475,6 +480,8 @@ bool Fuzzer::RunOne(const uint8_t *Data, size_t Size, bool MayDeleteFile,
TPC.CollectFeatures([&](size_t Feature) {
if (Corpus.AddFeature(Feature, Size, Options.Shrink))
UniqFeatureSetTmp.push_back(Feature);
+ //if (Options.Entropic)
+ Corpus.UpdateFeatureFrequency(II, Feature);
if (Options.ReduceInputs && II)
if (std::binary_search(II->UniqFeatureSet.begin(),
II->UniqFeatureSet.end(), Feature))
@@ -484,11 +491,52 @@ bool Fuzzer::RunOne(const uint8_t *Data, size_t Size, bool MayDeleteFile,
*FoundUniqFeatures = FoundUniqFeaturesOfII;
PrintPulseAndReportSlowInput(Data, Size);
size_t NumNewFeatures = Corpus.NumFeatureUpdates() - NumUpdatesBefore;
+ if (Corpus.ForkMode) {
+ if (Corpus.ForkSuccessful) {
+ Corpus.MaxMutationsInFork = Corpus.MaxMutationsInFork>Corpus.MutationsInFork ? Corpus.MaxMutationsInFork : Corpus.MutationsInFork;
+ Corpus.AvgMutationsInFork += Corpus.MutationsInFork;
+ Corpus.MutationsInFork = 0;
+ Corpus.ForksCounter++;
+ Corpus.ForkSuccessful = false;
+ }
+ if(Corpus.ForksCounter >= Corpus.ForkLimit) { // reset,
+ Corpus.GlobalMaxForkMutations = Corpus.MaxMutationsInFork; // just add max fork val
+ Corpus.AvgMutationsInFork /= Corpus.ForkLimit; // average it
+ Corpus.GlobalAvgForkMutations = Corpus.AvgMutationsInFork; // just add average fork val
+ Corpus.ForksCounter = 0;
+ Corpus.SeedsCounter = 0;
+ Corpus.ForkMode = false;
+ Corpus.MaxMutationsInFork = 0;
+ Corpus.AvgMutationsInFork = 0;
+ }
+ return false;
+ }
+
if (NumNewFeatures) {
+ if(II) {
+ Corpus.SeedsCounter++;
+ if(Corpus.SeedsCounter >= Corpus.SeedsLimit) {
+ Corpus.ForkMode = true; // start fork mode from next seed
+ Corpus.GlobalExecRate = execPerSec();
+ }
+
+ for (auto el : Corpus.TmpSeedTrialMap) {
+ if(el.first != II->SeedID)
+ Corpus.GlobalFailsVector.push_back(el.second); // Store updated fails except current seed
+ }
+ Corpus.TrialsToSuccess = Corpus.TmpSeedTrialMap[II->SeedID];
+ Corpus.GlobalFeats = NumNewFeatures;
+ Corpus.CalcEst();
+ // II->NumOfMutationAttempts = 0; // reset the mutation attempts only for that seed
+ // Corpus.SeedTrialMap[II->SeedID] = 0; // and reset it in the map
+ Corpus.PrintCSV();
+ Corpus.TmpSeedTrialMap.clear();
+ }
TPC.UpdateObservedPCs();
auto NewII = Corpus.AddToCorpus({Data, Data + Size}, NumNewFeatures,
MayDeleteFile, TPC.ObservedFocusFunction(),
UniqFeatureSetTmp, DFT, II);
+ if (!NewII) return false;
WriteFeatureSetToFile(Options.FeaturesDir, Sha1ToString(NewII->Sha1),
NewII->UniqFeatureSet);
return true;
@@ -551,7 +599,7 @@ void Fuzzer::ExecuteCallback(const uint8_t *Data, size_t Size) {
ScopedEnableMsanInterceptorChecks S;
AllocTracer.Start(Options.TraceMalloc);
UnitStartTime = system_clock::now();
- TPC.ResetMaps();
+ TPC.ResetMaps();
RunningUserCallback = true;
int Res = CB(DataCopy, Size);
RunningUserCallback = false;
@@ -592,9 +640,12 @@ void Fuzzer::WriteUnitToFileWithPrefix(const Unit &U, const char *Prefix) {
}
void Fuzzer::PrintStatusForNewUnit(const Unit &U, const char *Text) {
+ return; // blocking this for now
if (!Options.PrintNEW)
return;
PrintStats(Text, "");
+ if (!Options.Entropic)
+ return;
if (Options.Verbosity) {
Printf(" L: %zd/%zd ", U.size(), Corpus.MaxInputSize());
MD.PrintMutationSequence();
@@ -674,8 +725,7 @@ void Fuzzer::MutateAndTestOne() {
size_t CurrentMaxMutationLen =
Min(MaxMutationLen, Max(U.size(), TmpMaxMutationLen));
- assert(CurrentMaxMutationLen > 0);
-
+ assert(CurrentMaxMutationLen > 0);
for (int i = 0; i < Options.MutateDepth; i++) {
if (TotalNumberOfRuns >= Options.MaxNumberOfRuns)
break;
@@ -692,7 +742,14 @@ void Fuzzer::MutateAndTestOne() {
assert(NewSize > 0 && "Mutator returned empty unit");
assert(NewSize <= CurrentMaxMutationLen && "Mutator return oversized unit");
Size = NewSize;
- II.NumExecutedMutations++;
+ if (Corpus.ForkMode)
+ Corpus.MutationsInFork++;
+ else {
+ Corpus.TmpSeedTrialMap[II.SeedID]++;
+ // II.NumOfMutationAttempts++;
+ II.NumExecutedMutations++;
+ Corpus.IncrementNumExecutedMutations();
+ }
bool FoundUniqFeatures = false;
bool NewCov = RunOne(CurrentUnitData, Size, /*MayDeleteFile=*/true, &II,
@@ -706,6 +763,7 @@ void Fuzzer::MutateAndTestOne() {
if (Options.ReduceDepth && !FoundUniqFeatures)
break;
}
+ II.NeedsEnergyUpdate = true;
}
void Fuzzer::PurgeAllocator() {
diff --git a/compiler-rt/lib/fuzzer/FuzzerOptions.h b/compiler-rt/lib/fuzzer/FuzzerOptions.h
index beecc980380b..9d975bd61fe7 100644
--- a/compiler-rt/lib/fuzzer/FuzzerOptions.h
+++ b/compiler-rt/lib/fuzzer/FuzzerOptions.h
@@ -44,6 +44,9 @@ struct FuzzingOptions {
size_t MaxNumberOfRuns = -1L;
int ReportSlowUnits = 10;
bool OnlyASCII = false;
+ bool Entropic = false;
+ size_t EntropicFeatureFrequencyThreshold = 0xFF;
+ size_t EntropicNumberOfRarestFeatures = 100;
std::string OutputCorpus;
std::string ArtifactPrefix = "./";
std::string ExactArtifactPath;
diff --git a/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp b/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp
index 86649f9e095c..451afec2e13e 100644
--- a/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp
@@ -180,12 +180,12 @@ void TracePC::UpdateObservedPCs() {
}