1 // This file is distributed under the University of Illinois Open Source 2 // License. See LICENSE.TXT for details. 3 4 // Tests that deadlocks do not occur when an OOM occurs during symbolization. 5 6 #include <cassert> 7 #include <cstdint> 8 #include <cstdio> 9 #include <cstdlib> 10 #include <cstring> 11 #include <unistd.h> 12 13 #include "Bingo.h" 14 15 volatile unsigned Sink = 0; 16 17 // Do not inline this function. We want to trigger NEW_FUNC symbolization when 18 // libFuzzer finds this function. We use a macro to make the name as long 19 // possible, hoping to increase the time spent in symbolization and increase the 20 // chances of triggering a deadlock. 21 __attribute__((noinline)) void BINGO() { 22 // Busy work. Inserts a delay here so the deadlock is more likely to trigger. 23 for (unsigned i = 0; i < 330000000; i++) Sink += i; 24 } 25 26 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 27 assert(Data); 28 if (Size < 3) return 0; 29 if (Data[0] == 'F' && 30 Data[1] == 'U' && 31 Data[2] == 'Z') 32 BINGO(); 33 return 0; 34 } 35 36