[llvm-commits] [llvm] r99762 - /llvm/trunk/include/llvm/System/Memory.h

Torok Edwin edwintorok at gmail.com
Sun Mar 28 04:07:37 PDT 2010


Author: edwin
Date: Sun Mar 28 06:07:36 2010
New Revision: 99762

URL: http://llvm.org/viewvc/llvm-project?rev=99762&view=rev
Log:
Fix use-of-uninitialized value when RWX memory can't be allocated (PR6701).

SELinux doesn't allow 'execmem', returning MAP_FAILED and 'Permission denied'
for mmap or RWX memory. In this case AllocateRWX was returning a MemoryBlock
with uninitialized fields, which sometimes caused crashes.

This patch initializes MemoryBlock fields to 0, so that the RWX-failure check
works.
It doesn't fix the SELinux 'execmem' issues though (the JIT will not work when
SELinux is in enforcing mode).

Modified:
    llvm/trunk/include/llvm/System/Memory.h

Modified: llvm/trunk/include/llvm/System/Memory.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Memory.h?rev=99762&r1=99761&r2=99762&view=diff
==============================================================================
--- llvm/trunk/include/llvm/System/Memory.h (original)
+++ llvm/trunk/include/llvm/System/Memory.h Sun Mar 28 06:07:36 2010
@@ -27,7 +27,7 @@
   /// @brief Memory block abstraction.
   class MemoryBlock {
   public:
-    MemoryBlock() { }
+    MemoryBlock() : Address(0), Size(0) { }
     MemoryBlock(void *addr, size_t size) : Address(addr), Size(size) { }
     void *base() const { return Address; }
     size_t size() const { return Size; }





More information about the llvm-commits mailing list