This method is not inlined because it would cause a test to fail where it is part of the stack unwinding. See D97975 for details.
| 603 | // This method is not inlined because it would cause a test to fail where it |
| 604 | // is part of the stack unwinding. See D97975 for details. |
| 605 | ATTRIBUTE_NOINLINE bool Fuzzer::ExecuteCallback(const uint8_t *Data, |
| 606 | size_t Size) { |
| 607 | TPC.RecordInitialStack(); |
| 608 | TotalNumberOfRuns++; |
| 609 | assert(InFuzzingThread()); |
| 610 | // We copy the contents of Unit into a separate heap buffer |
| 611 | // so that we reliably find buffer overflows in it. |
| 612 | uint8_t *DataCopy = new uint8_t[Size]; |
| 613 | memcpy(DataCopy, Data, Size); |
| 614 | if (EF->__msan_unpoison) |
| 615 | EF->__msan_unpoison(DataCopy, Size); |
| 616 | if (EF->__msan_unpoison_param) |
| 617 | EF->__msan_unpoison_param(2); |
| 618 | if (CurrentUnitData && CurrentUnitData != Data) |
| 619 | memcpy(CurrentUnitData, Data, Size); |
| 620 | CurrentUnitSize = Size; |
| 621 | int CBRes = 0; |
| 622 | { |
| 623 | ScopedEnableMsanInterceptorChecks S; |
| 624 | AllocTracer.Start(Options.TraceMalloc); |
| 625 | UnitStartTime = system_clock::now(); |
| 626 | TPC.ResetMaps(); |
| 627 | RunningUserCallback = true; |
| 628 | CBRes = CB(DataCopy, Size); |
| 629 | RunningUserCallback = false; |
| 630 | UnitStopTime = system_clock::now(); |
| 631 | assert(CBRes == 0 || CBRes == -1); |
| 632 | HasMoreMallocsThanFrees = AllocTracer.Stop(); |
| 633 | } |
| 634 | if (!LooseMemeq(DataCopy, Data, Size)) |
| 635 | CrashOnOverwrittenData(); |
| 636 | CurrentUnitSize = 0; |
| 637 | delete[] DataCopy; |
| 638 | return CBRes == 0; |
| 639 | } |
| 640 | |
| 641 | std::string Fuzzer::WriteToOutputCorpus(const Unit &U) { |
| 642 | if (Options.OnlyASCII) |
no test coverage detected