Skip to content

Commit

Permalink
Add fuzzer for RateCalculator class
Browse files Browse the repository at this point in the history
### Details

- This new fuzzer should trigger the crash reported in issue #1316.
- However it doesn't :(

With debugging logs (removed in the PR) it runs as follows:

```
----- rateCalculator.Update() [size:1478, nowMs:333916840]
----- rateCalculator.Update() [size:943, nowMs:333916840]
----- rateCalculator.Update() [size:564, nowMs:333916840]
----- rateCalculator.Update() [size:1384, nowMs:333916841]
----- rateCalculator.Update() [size:889, nowMs:333916841]
----- rateCalculator.Update() [size:1134, nowMs:333916841]
----- rateCalculator.Update() [size:1001, nowMs:333916841]
----- rateCalculator.Update() [size:54, nowMs:333916841]
----- rateCalculator.Update() [size:923, nowMs:333916841]
----- rateCalculator.Update() [size:244, nowMs:333916841]
----- rateCalculator.Update() [size:1257, nowMs:333916842]
----- rateCalculator.Update() [size:1082, nowMs:333916842]
----- rateCalculator.Update() [size:1498, nowMs:333916842]
----- rateCalculator.Update() [size:670, nowMs:333916842]
----- rateCalculator.Update() [size:59, nowMs:333916842]
----- rateCalculator.Update() [size:987, nowMs:333916842]
----- rateCalculator.Update() [size:1448, nowMs:333916843]
----- rateCalculator.Update() [size:728, nowMs:333916843]
----- rateCalculator.Update() [size:1225, nowMs:333916843]
----- rateCalculator.Update() [size:1177, nowMs:333916843]
----- rateCalculator.Update() [size:1478, nowMs:333916844]
----- rateCalculator.Update() [size:257, nowMs:333916844]
----- rateCalculator.Update() [size:953, nowMs:333916844]
----- rateCalculator.Update() [size:629, nowMs:333916844]
----- rateCalculator.Update() [size:4, nowMs:333916844]
----- rateCalculator.Update() [size:472, nowMs:333916844]
----- rateCalculator.Update() [size:872, nowMs:333916845]
----- rateCalculator.Update() [size:1268, nowMs:333916846]
----- rateCalculator.Update() [size:40, nowMs:333916846]
----- rateCalculator.Update() [size:1423, nowMs:333916847]
----- rateCalculator.Update() [size:942, nowMs:333916847]
----- rateCalculator.Update() [size:276, nowMs:333916847]
----- rateCalculator.Update() [size:379, nowMs:333916848]
***** rateCalculator.GetRate()
----- rateCalculator.Update() [size:422, nowMs:333916848]
***** rateCalculator.GetRate()
----- rateCalculator.Update() [size:586, nowMs:333916848]
***** rateCalculator.GetRate()
----- rateCalculator.Update() [size:1224, nowMs:333916848]
***** rateCalculator.GetRate()
----- rateCalculator.Update() [size:416, nowMs:333916848]
----- rateCalculator.Update() [size:430, nowMs:333916849]
----- rateCalculator.Update() [size:731, nowMs:333916849]
----- rateCalculator.Update() [size:758, nowMs:333916850]
----- rateCalculator.Update() [size:328, nowMs:333916851]
----- rateCalculator.Update() [size:1429, nowMs:333916851]
----- rateCalculator.Update() [size:312, nowMs:333916851]
----- rateCalculator.Update() [size:897, nowMs:333916851]
----- rateCalculator.Update() [size:404, nowMs:333916851]
----- rateCalculator.Update() [size:218, nowMs:333916851]
----- rateCalculator.Update() [size:887, nowMs:333916852]
----- rateCalculator.Update() [size:643, nowMs:333916852]
----- rateCalculator.Update() [size:54, nowMs:333916853]
----- rateCalculator.Update() [size:1428, nowMs:333916853]
----- rateCalculator.Update() [size:1371, nowMs:333916854]
----- rateCalculator.Update() [size:314, nowMs:333916854]
----- rateCalculator.Update() [size:1248, nowMs:333916854]
----- rateCalculator.Update() [size:512, nowMs:333916854]
----- rateCalculator.Update() [size:997, nowMs:333916855]
----- rateCalculator.Update() [size:118, nowMs:333916855]
----- rateCalculator.Update() [size:1496, nowMs:333916855]
----- rateCalculator.Update() [size:341, nowMs:333916855]
----- rateCalculator.Update() [size:1443, nowMs:333916855]
***** rateCalculator.GetRate()
----- rateCalculator.Update() [size:1303, nowMs:333916855]
***** rateCalculator.GetRate()
----- rateCalculator.Update() [size:1238, nowMs:333916856]
***** rateCalculator.GetRate()
----- rateCalculator.Update() [size:692, nowMs:333916856]
----- rateCalculator.Update() [size:994, nowMs:333916856]
----- rateCalculator.Update() [size:570, nowMs:333916856]
----- rateCalculator.Update() [size:1213, nowMs:333916857]
----- rateCalculator.Update() [size:952, nowMs:333916857]
----- rateCalculator.Update() [size:766, nowMs:333916857]
----- rateCalculator.Update() [size:295, nowMs:333916857]
----- rateCalculator.Update() [size:1451, nowMs:333916857]
----- rateCalculator.Update() [size:1336, nowMs:333916857]
----- rateCalculator.Update() [size:687, nowMs:333916858]
----- rateCalculator.Update() [size:87, nowMs:333916858]
----- rateCalculator.Update() [size:1039, nowMs:333916858]
----- rateCalculator.Update() [size:1154, nowMs:333916858]
----- rateCalculator.Update() [size:1235, nowMs:333916859]
----- rateCalculator.Update() [size:439, nowMs:333916859]
----- rateCalculator.Update() [size:265, nowMs:333916859]
----- rateCalculator.Update() [size:1223, nowMs:333916860]
----- rateCalculator.Update() [size:47, nowMs:333916861]
----- rateCalculator.Update() [size:730, nowMs:333916861]
----- rateCalculator.Update() [size:1371, nowMs:333916862]
----- rateCalculator.Update() [size:582, nowMs:333916862]
----- rateCalculator.Update() [size:155, nowMs:333916862]
----- rateCalculator.Update() [size:1388, nowMs:333916862]
----- rateCalculator.Update() [size:348, nowMs:333916863]
----- rateCalculator.Update() [size:916, nowMs:333916863]
----- rateCalculator.Update() [size:485, nowMs:333916863]
----- rateCalculator.Update() [size:813, nowMs:333916863]
----- rateCalculator.Update() [size:1444, nowMs:333916863]
----- rateCalculator.Update() [size:781, nowMs:333916864]
----- rateCalculator.Update() [size:1093, nowMs:333916864]
----- rateCalculator.Update() [size:1425, nowMs:333916865]
----- rateCalculator.Update() [size:568, nowMs:333916865]
----- rateCalculator.Update() [size:1355, nowMs:333916865]
----- rateCalculator.Update() [size:1372, nowMs:333916865]
----- rateCalculator.Update() [size:735, nowMs:333916865]
----- rateCalculator.Update() [size:318, nowMs:333916865]
----- rateCalculator.Update() [size:1367, nowMs:333916865]
----- rateCalculator.Update() [size:1267, nowMs:333916866]
----- rateCalculator.Update() [size:765, nowMs:333916866]
----- rateCalculator.Update() [size:1024, nowMs:333916866]
----- rateCalculator.Update() [size:125, nowMs:333916867]
----- rateCalculator.Update() [size:68, nowMs:333916867]
----- rateCalculator.Update() [size:1014, nowMs:333916867]
----- rateCalculator.Update() [size:465, nowMs:333916868]
----- rateCalculator.Update() [size:1376, nowMs:333916868]
----- rateCalculator.Update() [size:997, nowMs:333916869]
----- rateCalculator.Update() [size:233, nowMs:333916869]
----- rateCalculator.Update() [size:1031, nowMs:333916870]
----- rateCalculator.Update() [size:790, nowMs:333916870]
----- rateCalculator.Update() [size:62, nowMs:333916870]
----- rateCalculator.Update() [size:300, nowMs:333916871]
----- rateCalculator.Update() [size:72, nowMs:333916871]
----- rateCalculator.Update() [size:216, nowMs:333916872]
----- rateCalculator.Update() [size:1440, nowMs:333916872]
----- rateCalculator.Update() [size:1141, nowMs:333916873]
----- rateCalculator.Update() [size:1477, nowMs:333916873]
----- rateCalculator.Update() [size:1313, nowMs:333916873]
----- rateCalculator.Update() [size:1154, nowMs:333916874]
----- rateCalculator.Update() [size:1049, nowMs:333916875]
----- rateCalculator.Update() [size:645, nowMs:333916875]
----- rateCalculator.Update() [size:475, nowMs:333916875]
----- rateCalculator.Update() [size:409, nowMs:333916876]
----- rateCalculator.Update() [size:669, nowMs:333916877]
----- rateCalculator.Update() [size:1075, nowMs:333916877]
----- rateCalculator.Update() [size:1386, nowMs:333916878]
----- rateCalculator.Update() [size:1129, nowMs:333916879]
----- rateCalculator.Update() [size:1103, nowMs:333916879]
----- rateCalculator.Update() [size:915, nowMs:333916880]
----- rateCalculator.Update() [size:795, nowMs:333916881]
----- rateCalculator.Update() [size:684, nowMs:333916881]
----- rateCalculator.Update() [size:321, nowMs:333916882]
----- rateCalculator.Update() [size:1312, nowMs:333916883]
----- rateCalculator.Update() [size:682, nowMs:333916883]
----- rateCalculator.Update() [size:1281, nowMs:333916884]
----- rateCalculator.Update() [size:528, nowMs:333916884]
----- rateCalculator.Update() [size:1483, nowMs:333916884]
----- rateCalculator.Update() [size:596, nowMs:333916885]
----- rateCalculator.Update() [size:1423, nowMs:333916885]
----- rateCalculator.Update() [size:1271, nowMs:333916885]
----- rateCalculator.Update() [size:256, nowMs:333916885]
----- rateCalculator.Update() [size:193, nowMs:333916885]
----- rateCalculator.Update() [size:623, nowMs:333916885]
----- rateCalculator.Update() [size:39, nowMs:333916886]
----- rateCalculator.Update() [size:635, nowMs:333916886]
----- rateCalculator.Update() [size:515, nowMs:333916886]
----- rateCalculator.Update() [size:856, nowMs:333916886]
----- rateCalculator.Update() [size:636, nowMs:333916886]
----- rateCalculator.Update() [size:882, nowMs:333916886]
----- rateCalculator.Update() [size:791, nowMs:333916887]
----- rateCalculator.Update() [size:12, nowMs:333916887]
----- rateCalculator.Update() [size:1083, nowMs:333916888]
----- rateCalculator.Update() [size:101, nowMs:333916888]
----- rateCalculator.Update() [size:1391, nowMs:333916889]
----- rateCalculator.Update() [size:764, nowMs:333916889]
----- rateCalculator.Update() [size:1285, nowMs:333916890]
----- rateCalculator.Update() [size:1015, nowMs:333916890]
----- rateCalculator.Update() [size:306, nowMs:333916890]
----- rateCalculator.Update() [size:605, nowMs:333916890]
----- rateCalculator.Update() [size:1276, nowMs:333916890]
----- rateCalculator.Update() [size:510, nowMs:333916890]
----- rateCalculator.Update() [size:1328, nowMs:333916891]
----- rateCalculator.Update() [size:138, nowMs:333916892]
----- rateCalculator.Update() [size:797, nowMs:333916892]
----- rateCalculator.Update() [size:1445, nowMs:333916893]
----- rateCalculator.Update() [size:84, nowMs:333916893]
----- rateCalculator.Update() [size:908, nowMs:333916893]
----- rateCalculator.Update() [size:84, nowMs:333916894]
----- rateCalculator.Update() [size:789, nowMs:333916894]
----- rateCalculator.Update() [size:36, nowMs:333916894]
----- rateCalculator.Update() [size:444, nowMs:333916894]
----- rateCalculator.Update() [size:486, nowMs:333916895]
----- rateCalculator.Update() [size:1233, nowMs:333916895]
----- rateCalculator.Update() [size:11, nowMs:333916896]
----- rateCalculator.Update() [size:773, nowMs:333916897]
----- rateCalculator.Update() [size:1272, nowMs:333916897]
----- rateCalculator.Update() [size:148, nowMs:333916898]
----- rateCalculator.Update() [size:404, nowMs:333916898]
----- rateCalculator.Update() [size:1316, nowMs:333916899]
----- rateCalculator.Update() [size:1317, nowMs:333916899]
----- rateCalculator.Update() [size:232, nowMs:333916900]
----- rateCalculator.Update() [size:1270, nowMs:333916900]
----- rateCalculator.Update() [size:277, nowMs:333916900]
----- rateCalculator.Update() [size:1091, nowMs:333916900]
----- rateCalculator.Update() [size:1271, nowMs:333916901]
----- rateCalculator.Update() [size:610, nowMs:333916901]
----- rateCalculator.Update() [size:42, nowMs:333916901]
***** rateCalculator.GetRate()
----- rateCalculator.Update() [size:244, nowMs:333916901]
***** rateCalculator.GetRate()
----- rateCalculator.Update() [size:1280, nowMs:333916901]
***** rateCalculator.GetRate()
----- rateCalculator.Update() [size:302, nowMs:333916901]
***** rateCalculator.GetRate()
----- rateCalculator.Update() [size:130, nowMs:333916901]
***** rateCalculator.GetRate()
----- rateCalculator.Update() [size:68, nowMs:333916902]
----- rateCalculator.Update() [size:110, nowMs:333916902]
----- rateCalculator.Update() [size:748, nowMs:333916903]
----- rateCalculator.Update() [size:1168, nowMs:333916903]
----- rateCalculator.Update() [size:1326, nowMs:333916904]
----- rateCalculator.Update() [size:582, nowMs:333916904]
----- rateCalculator.Update() [size:679, nowMs:333916904]
----- rateCalculator.Update() [size:1489, nowMs:333916905]
----- rateCalculator.Update() [size:420, nowMs:333916906]
----- rateCalculator.Update() [size:394, nowMs:333916906]
----- rateCalculator.Update() [size:718, nowMs:333916907]
----- rateCalculator.Update() [size:1431, nowMs:333916907]
----- rateCalculator.Update() [size:1437, nowMs:333916907]
----- rateCalculator.Update() [size:1, nowMs:333916907]
----- rateCalculator.Update() [size:617, nowMs:333916907]
----- rateCalculator.Update() [size:1430, nowMs:333916908]
----- rateCalculator.Update() [size:1158, nowMs:333916908]
----- rateCalculator.Update() [size:1232, nowMs:333916908]
----- rateCalculator.Update() [size:1113, nowMs:333916909]
----- rateCalculator.Update() [size:401, nowMs:333916909]
----- rateCalculator.Update() [size:657, nowMs:333916910]
----- rateCalculator.Update() [size:1254, nowMs:333916910]
----- rateCalculator.Update() [size:47, nowMs:333916910]
----- rateCalculator.Update() [size:847, nowMs:333916910]
----- rateCalculator.Update() [size:576, nowMs:333916910]
----- rateCalculator.Update() [size:550, nowMs:333916911]
----- rateCalculator.Update() [size:358, nowMs:333916911]
----- rateCalculator.Update() [size:1212, nowMs:333916911]
----- rateCalculator.Update() [size:455, nowMs:333916911]
----- rateCalculator.Update() [size:723, nowMs:333916911]
----- rateCalculator.Update() [size:605, nowMs:333916912]
----- rateCalculator.Update() [size:1042, nowMs:333916912]
----- rateCalculator.Update() [size:702, nowMs:333916912]
----- rateCalculator.Update() [size:1496, nowMs:333916912]
----- rateCalculator.Update() [size:183, nowMs:333916912]
----- rateCalculator.Update() [size:1201, nowMs:333916913]
----- rateCalculator.Update() [size:1040, nowMs:333916913]
----- rateCalculator.Update() [size:1070, nowMs:333916914]
----- rateCalculator.Update() [size:1391, nowMs:333916915]
----- rateCalculator.Update() [size:1089, nowMs:333916915]
----- rateCalculator.Update() [size:1219, nowMs:333916916]
----- rateCalculator.Update() [size:173, nowMs:333917833]
----- rateCalculator.Update() [size:381, nowMs:333917834]
----- rateCalculator.Update() [size:1493, nowMs:333917834]
----- rateCalculator.Update() [size:1105, nowMs:333917835]
----- rateCalculator.Update() [size:1443, nowMs:333917835]
----- rateCalculator.Update() [size:1410, nowMs:333917836]
----- rateCalculator.Update() [size:1413, nowMs:333917836]
----- rateCalculator.Update() [size:115, nowMs:333917836]
----- rateCalculator.Update() [size:388, nowMs:333917836]
----- rateCalculator.Update() [size:1315, nowMs:333917836]
----- rateCalculator.Update() [size:1222, nowMs:333917837]
----- rateCalculator.Update() [size:528, nowMs:333917837]
----- rateCalculator.Update() [size:720, nowMs:333917837]
----- rateCalculator.Update() [size:507, nowMs:333917837]
----- rateCalculator.Update() [size:696, nowMs:333917838]
----- rateCalculator.Update() [size:713, nowMs:333917838]
----- rateCalculator.Update() [size:185, nowMs:333917838]
----- rateCalculator.Update() [size:1255, nowMs:333917839]
----- rateCalculator.Update() [size:1462, nowMs:333917839]
----- rateCalculator.Update() [size:818, nowMs:333917839]
----- rateCalculator.Update() [size:199, nowMs:333917839]
----- rateCalculator.Update() [size:364, nowMs:333917840]
----- rateCalculator.Update() [size:420, nowMs:333917840]
----- rateCalculator.Update() [size:1492, nowMs:333917840]
----- rateCalculator.Update() [size:965, nowMs:333917841]
----- rateCalculator.Update() [size:927, nowMs:333917842]
----- rateCalculator.Update() [size:1208, nowMs:333917842]
----- rateCalculator.Update() [size:1104, nowMs:333917843]
----- rateCalculator.Update() [size:1040, nowMs:333917843]
----- rateCalculator.Update() [size:132, nowMs:333917843]
----- rateCalculator.Update() [size:395, nowMs:333917844]
----- rateCalculator.Update() [size:962, nowMs:333917844]
----- rateCalculator.Update() [size:1298, nowMs:333917844]
----- rateCalculator.Update() [size:303, nowMs:333917844]
----- rateCalculator.Update() [size:1474, nowMs:333917844]
----- rateCalculator.Update() [size:1084, nowMs:333917845]
----- rateCalculator.Update() [size:186, nowMs:333917845]
----- rateCalculator.Update() [size:819, nowMs:333917845]
----- rateCalculator.Update() [size:1009, nowMs:333917846]
----- rateCalculator.Update() [size:1060, nowMs:333917846]
----- rateCalculator.Update() [size:645, nowMs:333917846]
----- rateCalculator.Update() [size:4, nowMs:333917847]
----- rateCalculator.Update() [size:1300, nowMs:333917847]
----- rateCalculator.Update() [size:460, nowMs:333917847]
----- rateCalculator.Update() [size:318, nowMs:333917848]
----- rateCalculator.Update() [size:1030, nowMs:333917848]
----- rateCalculator.Update() [size:482, nowMs:333917848]
----- rateCalculator.Update() [size:228, nowMs:333917849]
----- rateCalculator.Update() [size:1379, nowMs:333917849]
----- rateCalculator.Update() [size:33, nowMs:333917849]
----- rateCalculator.Update() [size:321, nowMs:333917850]
----- rateCalculator.Update() [size:167, nowMs:333917850]
----- rateCalculator.Update() [size:810, nowMs:333917850]
----- rateCalculator.Update() [size:1369, nowMs:333917850]
----- rateCalculator.Update() [size:1236, nowMs:333917850]
----- rateCalculator.Update() [size:759, nowMs:333917850]
----- rateCalculator.Update() [size:95, nowMs:333917850]
----- rateCalculator.Update() [size:856, nowMs:333917851]
----- rateCalculator.Update() [size:185, nowMs:333917851]
----- rateCalculator.Update() [size:595, nowMs:333917851]
----- rateCalculator.Update() [size:432, nowMs:333917851]
----- rateCalculator.Update() [size:165, nowMs:333917851]
----- rateCalculator.Update() [size:607, nowMs:333917852]
----- rateCalculator.Update() [size:818, nowMs:333917852]
----- rateCalculator.Update() [size:30, nowMs:333917852]
----- rateCalculator.Update() [size:771, nowMs:333917852]
----- rateCalculator.Update() [size:1047, nowMs:333917852]
----- rateCalculator.Update() [size:920, nowMs:333917852]
----- rateCalculator.Update() [size:1099, nowMs:333917852]
----- rateCalculator.Update() [size:344, nowMs:333917853]
----- rateCalculator.Update() [size:1156, nowMs:333917853]
----- rateCalculator.Update() [size:527, nowMs:333917853]
----- rateCalculator.Update() [size:54, nowMs:333917853]
----- rateCalculator.Update() [size:639, nowMs:333917854]
----- rateCalculator.Update() [size:178, nowMs:333917855]
----- rateCalculator.Update() [size:870, nowMs:333917855]
----- rateCalculator.Update() [size:799, nowMs:333917856]
----- rateCalculator.Update() [size:462, nowMs:333917857]
----- rateCalculator.Update() [size:305, nowMs:333917857]
----- rateCalculator.Update() [size:1295, nowMs:333917857]
----- rateCalculator.Update() [size:1392, nowMs:333917857]
----- rateCalculator.Update() [size:318, nowMs:333917857]
----- rateCalculator.Update() [size:1177, nowMs:333917857]
----- rateCalculator.Update() [size:1214, nowMs:333917858]
***** rateCalculator.GetRate()
----- rateCalculator.Update() [size:624, nowMs:333917858]
***** rateCalculator.GetRate()
----- rateCalculator.Update() [size:1360, nowMs:333917858]
***** rateCalculator.GetRate()
----- rateCalculator.Update() [size:1185, nowMs:333917858]
----- rateCalculator.Update() [size:312, nowMs:333917858]
----- rateCalculator.Update() [size:1085, nowMs:333917858]
----- rateCalculator.Update() [size:808, nowMs:333917858]
----- rateCalculator.Update() [size:1056, nowMs:333917858]
----- rateCalculator.Update() [size:344, nowMs:333917858]
----- rateCalculator.Update() [size:619, nowMs:333917859]
----- rateCalculator.Update() [size:2, nowMs:333917859]
----- rateCalculator.Update() [size:765, nowMs:333917859]
----- rateCalculator.Update() [size:141, nowMs:333917859]
----- rateCalculator.Update() [size:109, nowMs:333917860]
----- rateCalculator.Update() [size:317, nowMs:333917860]
----- rateCalculator.Update() [size:591, nowMs:333917860]
----- rateCalculator.Update() [size:17, nowMs:333917861]
----- rateCalculator.Update() [size:651, nowMs:333917861]
----- rateCalculator.Update() [size:1151, nowMs:333917861]
----- rateCalculator.Update() [size:796, nowMs:333917862]
----- rateCalculator.Update() [size:551, nowMs:333917862]
----- rateCalculator.Update() [size:1414, nowMs:333917862]
----- rateCalculator.Update() [size:841, nowMs:333917862]
----- rateCalculator.Update() [size:1197, nowMs:333917862]
----- rateCalculator.Update() [size:1082, nowMs:333917863]
----- rateCalculator.Update() [size:1448, nowMs:333917863]
----- rateCalculator.Update() [size:863, nowMs:333917863]
----- rateCalculator.Update() [size:1185, nowMs:333917863]
----- rateCalculator.Update() [size:868, nowMs:333917863]
----- rateCalculator.Update() [size:460, nowMs:333917863]
----- rateCalculator.Update() [size:1386, nowMs:333917864]
----- rateCalculator.Update() [size:371, nowMs:333917864]
----- rateCalculator.Update() [size:219, nowMs:333917864]
----- rateCalculator.Update() [size:706, nowMs:333917864]
----- rateCalculator.Update() [size:972, nowMs:333917864]
----- rateCalculator.Update() [size:878, nowMs:333917864]
----- rateCalculator.Update() [size:567, nowMs:333917864]
----- rateCalculator.Update() [size:423, nowMs:333917865]
----- rateCalculator.Update() [size:1178, nowMs:333917865]
----- rateCalculator.Update() [size:1386, nowMs:333917865]
----- rateCalculator.Update() [size:849, nowMs:333917865]
----- rateCalculator.Update() [size:868, nowMs:333917865]
----- rateCalculator.Update() [size:1090, nowMs:333917865]
***** rateCalculator.GetRate()
----- rateCalculator.Update() [size:724, nowMs:333917865]
***** rateCalculator.GetRate()
----- rateCalculator.Update() [size:1076, nowMs:333917866]
----- rateCalculator.Update() [size:950, nowMs:333917866]
----- rateCalculator.Update() [size:1367, nowMs:333917866]
----- rateCalculator.Update() [size:991, nowMs:333917867]
```

I cannot make it crash :(
  • Loading branch information
ibc committed Mar 21, 2024
1 parent 8d757bc commit 102ae7d
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
17 changes: 17 additions & 0 deletions worker/fuzzer/include/RTC/FuzzerRateCalculator.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef MS_FUZZER_RTC_RATE_CALCULATOR_HPP
#define MS_FUZZER_RTC_RATE_CALCULATOR_HPP

#include "common.hpp"

namespace Fuzzer
{
namespace RTC
{
namespace RateCalculator
{
void Fuzz(const uint8_t* data, size_t len);
}
} // namespace RTC
} // namespace Fuzzer

#endif
28 changes: 28 additions & 0 deletions worker/fuzzer/src/RTC/FuzzerRateCalculator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "RTC/FuzzerRateCalculator.hpp"
#include "DepLibUV.hpp"
#include "Utils.hpp"
#include "RTC/RateCalculator.hpp"
#include "RTC/RtpPacket.hpp" // RTC::MtuSize

::RTC::RateCalculator rateCalculator;

void Fuzzer::RTC::RateCalculator::Fuzz(const uint8_t* data, size_t len)
{
// We need at least 2 bytes of |data|.
if (len < 2)
{
return;
}

auto size =
static_cast<size_t>(Utils::Crypto::GetRandomUInt(0u, static_cast<uint32_t>(::RTC::MtuSize)));
uint64_t nowMs = DepLibUV::GetTimeMs();

rateCalculator.Update(size, nowMs);

// Only get rate from time to time.
if (Utils::Byte::Get2Bytes(data, 0) % 100 == 0)
{
rateCalculator.GetRate(nowMs);
}
}
6 changes: 5 additions & 1 deletion worker/fuzzer/src/fuzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "RTC/Codecs/FuzzerVP9.hpp"
#include "RTC/DtlsTransport.hpp"
#include "RTC/FuzzerDtlsTransport.hpp"
#include "RTC/FuzzerRateCalculator.hpp"
#include "RTC/FuzzerRtpPacket.hpp"
#include "RTC/FuzzerRtpRetransmissionBuffer.hpp"
#include "RTC/FuzzerRtpStreamSend.hpp"
Expand All @@ -35,7 +36,9 @@ bool fuzzRtcp = false;
bool fuzzCodecs = false;
bool fuzzUtils = false;

int Init();
// This Init() function must be declared static, otherwise linking will fail if
// another source file defines same non static Init() function.
static int Init();

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t len)
{
Expand All @@ -61,6 +64,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t len)
Fuzzer::RTC::RtpStreamSend::Fuzz(data, len);
Fuzzer::RTC::RtpRetransmissionBuffer::Fuzz(data, len);
Fuzzer::RTC::SeqManager::Fuzz(data, len);
Fuzzer::RTC::RateCalculator::Fuzz(data, len);
}

if (fuzzRtcp)
Expand Down
1 change: 1 addition & 0 deletions worker/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ executable(
'fuzzer/src/fuzzer.cpp',
'fuzzer/src/FuzzerUtils.cpp',
'fuzzer/src/RTC/FuzzerDtlsTransport.cpp',
'fuzzer/src/RTC/FuzzerRateCalculator.cpp',
'fuzzer/src/RTC/FuzzerRtpPacket.cpp',
'fuzzer/src/RTC/FuzzerRtpRetransmissionBuffer.cpp',
'fuzzer/src/RTC/FuzzerRtpStreamSend.cpp',
Expand Down

0 comments on commit 102ae7d

Please sign in to comment.