[compiler-rt] r261837 - [Compiler-rt][MSan]Fix shmat testcase: Pass SHMLBA-alligned address to shmat
Mohit K. Bhakkad via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 25 00:07:44 PST 2016
Author: mohit.bhakkad
Date: Thu Feb 25 02:07:44 2016
New Revision: 261837
URL: http://llvm.org/viewvc/llvm-project?rev=261837&view=rev
Log:
[Compiler-rt][MSan]Fix shmat testcase: Pass SHMLBA-alligned address to shmat
Reviewers: samsonov
Subscribers: jaydeep, sagar, llvm-commits
Differential Revision: http://reviews.llvm.org/D17262
Modified:
compiler-rt/trunk/lib/msan/tests/msan_test.cc
Modified: compiler-rt/trunk/lib/msan/tests/msan_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/tests/msan_test.cc?rev=261837&r1=261836&r2=261837&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/tests/msan_test.cc (original)
+++ compiler-rt/trunk/lib/msan/tests/msan_test.cc Thu Feb 25 02:07:44 2016
@@ -1214,17 +1214,21 @@ TEST(MemorySanitizer, shmctl) {
}
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);
@@ -1232,7 +1236,7 @@ TEST(MemorySanitizer, shmat) {
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);
More information about the llvm-commits
mailing list