[PATCH] D17262: [Compiler-rt][MSan]Fix shmat testcase: Pass SHMLBA-alligned address to shmat
Mohit Bhakkad via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 25 00:12:18 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261837: [Compiler-rt][MSan]Fix shmat testcase: Pass SHMLBA-alligned address to shmat (authored by mohit.bhakkad).
Changed prior to commit:
http://reviews.llvm.org/D17262?vs=48920&id=49013#toc
Repository:
rL LLVM
http://reviews.llvm.org/D17262
Files:
compiler-rt/trunk/lib/msan/tests/msan_test.cc
Index: compiler-rt/trunk/lib/msan/tests/msan_test.cc
===================================================================
--- compiler-rt/trunk/lib/msan/tests/msan_test.cc
+++ compiler-rt/trunk/lib/msan/tests/msan_test.cc
@@ -1214,25 +1214,29 @@
}
TEST(MemorySanitizer, shmat) {
- void *p = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
- ASSERT_NE(MAP_FAILED, p);
+ const int kShmSize = 4096;
+ void *mapping_start = mmap(NULL, kShmSize + SHMLBA, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ ASSERT_NE(MAP_FAILED, mapping_start);
+
+ void *p = (void *)(((unsigned long)mapping_start + SHMLBA - 1) / SHMLBA * SHMLBA);
+ // p is now SHMLBA-aligned;
((char *)p)[10] = *GetPoisoned<U1>();
- ((char *)p)[4095] = *GetPoisoned<U1>();
+ ((char *)p)[kShmSize - 1] = *GetPoisoned<U1>();
- int res = munmap(p, 4096);
+ int res = munmap(mapping_start, kShmSize + SHMLBA);
ASSERT_EQ(0, res);
- int id = shmget(IPC_PRIVATE, 4096, 0644 | IPC_CREAT);
+ int id = shmget(IPC_PRIVATE, kShmSize, 0644 | IPC_CREAT);
ASSERT_GT(id, -1);
void *q = shmat(id, p, 0);
ASSERT_EQ(p, q);
EXPECT_NOT_POISONED(((char *)q)[0]);
EXPECT_NOT_POISONED(((char *)q)[10]);
- EXPECT_NOT_POISONED(((char *)q)[4095]);
+ EXPECT_NOT_POISONED(((char *)q)[kShmSize - 1]);
res = shmdt(q);
ASSERT_EQ(0, res);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17262.49013.patch
Type: text/x-patch
Size: 1416 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160225/61d9964d/attachment.bin>
More information about the llvm-commits
mailing list