Akira Hatanaka
2012-Dec-04 21:33 UTC
[LLVMdev] [PATCH][Review request] MappedMemoryTest: Prevent tests from running if read flag is not set.
The attached patch prevents MappedMemoryTest.BasicWrite and MappedMemoryTest.MultipleWrite (both in unittests/Support/MemoryTest.cpp) from running if the correct protection flags for memory allocation are not set. Without this patch, the two tests fail when I run "make check-all" on a mips octeon board. The problem with the current code is that it allocates a block of memory without setting the read flag. This results in a segfault at line 115 of MemoryTest.cpp where it reads the allocated block to check whether 1 has been written into the first word of the block. This patch fixes this, and checks that both read and write flags are set. unittests/Support/MemoryTest.cpp (line 101) TEST_P(MappedMemoryTest, BasicWrite) { // This test applies only to writeable combinations if (Flags && !(Flags & Memory::MF_WRITE)) return; MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC); ... int *a = (int*)M1.base(); *a = 1; EXPECT_EQ(1, *a); // This line segfaults. ... } -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121204/67fd4245/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: memorytest.patch Type: application/octet-stream Size: 1054 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121204/67fd4245/attachment.obj>
Kaylor, Andrew
2012-Dec-05 22:24 UTC
[LLVMdev] [PATCH][Review request] MappedMemoryTest: Prevent tests from running if read flag is not set.
Look good. -Andy From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Akira Hatanaka Sent: Tuesday, December 04, 2012 1:33 PM To: LLVM Developers Mailing List Subject: [LLVMdev] [PATCH][Review request] MappedMemoryTest: Prevent tests from running if read flag is not set. The attached patch prevents MappedMemoryTest.BasicWrite and MappedMemoryTest.MultipleWrite (both in unittests/Support/MemoryTest.cpp) from running if the correct protection flags for memory allocation are not set. Without this patch, the two tests fail when I run "make check-all" on a mips octeon board. The problem with the current code is that it allocates a block of memory without setting the read flag. This results in a segfault at line 115 of MemoryTest.cpp where it reads the allocated block to check whether 1 has been written into the first word of the block. This patch fixes this, and checks that both read and write flags are set. unittests/Support/MemoryTest.cpp (line 101) TEST_P(MappedMemoryTest, BasicWrite) { // This test applies only to writeable combinations if (Flags && !(Flags & Memory::MF_WRITE)) return; MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC); ... int *a = (int*)M1.base(); *a = 1; EXPECT_EQ(1, *a); // This line segfaults. ... } -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121205/a503d7e4/attachment.html>
Akira Hatanaka
2012-Dec-05 22:46 UTC
[LLVMdev] [PATCH][Review request] MappedMemoryTest: Prevent tests from running if read flag is not set.
Thanks, committed r169439. On Wed, Dec 5, 2012 at 2:24 PM, Kaylor, Andrew <andrew.kaylor at intel.com>wrote:> Look good.**** > > ** ** > > -Andy**** > > ** ** > > *From:* llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] *On > Behalf Of *Akira Hatanaka > *Sent:* Tuesday, December 04, 2012 1:33 PM > *To:* LLVM Developers Mailing List > *Subject:* [LLVMdev] [PATCH][Review request] MappedMemoryTest: Prevent > tests from running if read flag is not set.**** > > ** ** > > The attached patch prevents MappedMemoryTest.BasicWrite and > MappedMemoryTest.MultipleWrite (both in unittests/Support/MemoryTest.cpp) > from running if the correct protection flags for memory allocation are not > set. Without this patch, the two tests fail when I run "make check-all" on > a mips octeon board. > > The problem with the current code is that it allocates a block of memory > without setting the read flag. This results in a segfault at line 115 of > MemoryTest.cpp where it reads the allocated block to check whether 1 has > been written into the first word of the block. This patch fixes this, and > checks that both read and write flags are set. > > > unittests/Support/MemoryTest.cpp (line 101) > > TEST_P(MappedMemoryTest, BasicWrite) { > // This test applies only to writeable combinations > if (Flags && !(Flags & Memory::MF_WRITE)) > return; > > MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC); > ... > int *a = (int*)M1.base(); > *a = 1; > EXPECT_EQ(1, *a); // This line segfaults. > ... > }**** >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121205/e876ec06/attachment.html>
Apparently Analagous Threads
- [LLVMdev] [PATCH][Review request] MappedMemoryTest: Prevent tests from running if read flag is not set.
- "cannot allocate vector of size ..." in RHLE5 PAE kernel
- Memory mapping assumptions in RuntimeDyld
- [LLVMdev] mmap and vm_protect on ARM+Apple systems
- Problem launching Cursed mountain