From 993c4d6be0bcc826ccc1a735a09b875d8784ad7f Mon Sep 17 00:00:00 2001 From: Cristian Cadar Date: Wed, 28 Nov 2012 18:08:52 +0000 Subject: Only emitting a warning, instead of failing on large mallocs. Addresses the issue raised by Bowen Zhou at http://keeda.stanford.edu/pipermail/klee-dev/2012-November/000972.html. Fixed test case that depended on the old behavior. git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@168797 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Core/MemoryManager.cpp | 7 +++---- test/Feature/Realloc.c | 18 ++++++++++++++++++ test/Feature/ReallocFailure.c | 18 ------------------ 3 files changed, 21 insertions(+), 22 deletions(-) create mode 100644 test/Feature/Realloc.c delete mode 100644 test/Feature/ReallocFailure.c diff --git a/lib/Core/MemoryManager.cpp b/lib/Core/MemoryManager.cpp index 06c234a2..a1198007 100644 --- a/lib/Core/MemoryManager.cpp +++ b/lib/Core/MemoryManager.cpp @@ -36,10 +36,9 @@ MemoryManager::~MemoryManager() { MemoryObject *MemoryManager::allocate(uint64_t size, bool isLocal, bool isGlobal, const llvm::Value *allocSite) { - if (size>10*1024*1024) { - klee_warning_once(0, "failing large alloc: %u bytes", (unsigned) size); - return 0; - } + if (size>10*1024*1024) + klee_warning_once(0, "Large alloc: %u bytes. KLEE may run out of memory.", (unsigned) size); + uint64_t address = (uint64_t) (unsigned long) malloc((unsigned) size); if (!address) return 0; diff --git a/test/Feature/Realloc.c b/test/Feature/Realloc.c new file mode 100644 index 00000000..a47adad6 --- /dev/null +++ b/test/Feature/Realloc.c @@ -0,0 +1,18 @@ +// RUN: %llvmgcc %s -emit-llvm -O0 -c -o %t1.bc +// RUN: %klee --exit-on-error %t1.bc +// RUN: grep "KLEE: WARNING ONCE: Large alloc" klee-last/warnings.txt + +#include +#include +#include + +int main() { + int *p = malloc(sizeof(int)*2); + assert(p); + p[1] = 52; + + int *p2 = realloc(p, 1<<30); + assert(p2[1] == 52); + + return 0; +} diff --git a/test/Feature/ReallocFailure.c b/test/Feature/ReallocFailure.c deleted file mode 100644 index e5105c33..00000000 --- a/test/Feature/ReallocFailure.c +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: %llvmgcc %s -emit-llvm -O0 -c -o %t1.bc -// RUN: %klee --exit-on-error %t1.bc - -#include -#include -#include - -int main() { - int *p = malloc(sizeof(int)*2); - assert(p); - p[1] = 52; - - int *p2 = realloc(p, 1<<30); - assert(p2 == 0); - assert(p[1] == 52); - - return 0; -} -- cgit 1.4.1