From de18bba4c826fd2b9a1c7352008bc692fce48756 Mon Sep 17 00:00:00 2001 From: Sean Callanan Date: Wed, 15 Aug 2012 20:53:52 +0000 Subject: [PATCH] Fixed a problem in the JIT memory allocator where allocations of executable memory would not be padded to account for the size of the allocation header. This resulted in undersized allocations, meaning that when the allocation was written to later the next allocation's header would be corrupted. llvm-svn: 161984 --- lib/ExecutionEngine/JIT/JITMemoryManager.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/ExecutionEngine/JIT/JITMemoryManager.cpp b/lib/ExecutionEngine/JIT/JITMemoryManager.cpp index 7be6ef8cba9..61bc119d305 100644 --- a/lib/ExecutionEngine/JIT/JITMemoryManager.cpp +++ b/lib/ExecutionEngine/JIT/JITMemoryManager.cpp @@ -461,6 +461,9 @@ namespace { /// allocateCodeSection - Allocate memory for a code section. uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment, unsigned SectionID) { + // Grow the required block size to account for the block header + Size += sizeof(*CurBlock); + // FIXME: Alignement handling. FreeRangeHeader* candidateBlock = FreeMemoryList; FreeRangeHeader* head = FreeMemoryList;