[llvm-commits] [llvm] r161984 - /llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp

Sean Callanan scallanan at apple.com
Wed Aug 15 13:53:52 PDT 2012


Author: spyffe
Date: Wed Aug 15 15:53:52 2012
New Revision: 161984

URL: http://llvm.org/viewvc/llvm-project?rev=161984&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp

Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp?rev=161984&r1=161983&r2=161984&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp Wed Aug 15 15:53:52 2012
@@ -461,6 +461,9 @@
     /// 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;





More information about the llvm-commits mailing list