[compiler-rt] r180101 - [msan] Unpoison the result of posix_memalign.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Wed Apr 24 00:47:08 PDT 2013
By "result" I mean the pointer itself, not the allocated memory.
On Wed, Apr 24, 2013 at 3:53 AM, Kostya Serebryany <kcc at google.com> wrote:
> Why?
>
>
> On Tue, Apr 23, 2013 at 6:27 AM, Evgeniy Stepanov
> <eugeni.stepanov at gmail.com> wrote:
>>
>> Author: eugenis
>> Date: Tue Apr 23 08:27:36 2013
>> New Revision: 180101
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=180101&view=rev
>> Log:
>> [msan] Unpoison the result of posix_memalign.
>>
>> Modified:
>> compiler-rt/trunk/lib/msan/msan_interceptors.cc
>> compiler-rt/trunk/lib/msan/tests/msan_test.cc
>>
>> Modified: compiler-rt/trunk/lib/msan/msan_interceptors.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interceptors.cc?rev=180101&r1=180100&r2=180101&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/lib/msan/msan_interceptors.cc (original)
>> +++ compiler-rt/trunk/lib/msan/msan_interceptors.cc Tue Apr 23 08:27:36
>> 2013
>> @@ -114,8 +114,10 @@ INTERCEPTOR(void *, memset, void *s, int
>> INTERCEPTOR(int, posix_memalign, void **memptr, SIZE_T alignment, SIZE_T
>> size) {
>> GET_MALLOC_STACK_TRACE;
>> CHECK_EQ(alignment & (alignment - 1), 0);
>> - *memptr = MsanReallocate(&stack, 0, size, alignment, false);
>> CHECK_NE(memptr, 0);
>> + *memptr = MsanReallocate(&stack, 0, size, alignment, false);
>> + CHECK_NE(*memptr, 0);
>> + __msan_unpoison(memptr, sizeof(*memptr));
>> return 0;
>> }
>>
>>
>> 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=180101&r1=180100&r2=180101&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/lib/msan/tests/msan_test.cc (original)
>> +++ compiler-rt/trunk/lib/msan/tests/msan_test.cc Tue Apr 23 08:27:36 2013
>> @@ -1627,6 +1627,15 @@ TEST(MemorySanitizer, PreAllocatedStackT
>> ASSERT_EQ(0, res);
>> }
>>
>> +TEST(MemorySanitizer, posix_memalign) {
>> + void *p;
>> + EXPECT_POISONED(p);
>> + int res = posix_memalign(&p, 4096, 13);
>> + ASSERT_EQ(0, res);
>> + EXPECT_NOT_POISONED(p);
>> + free(p);
>> +}
>> +
>> TEST(MemorySanitizer, uname) {
>> struct utsname u;
>> int res = uname(&u);
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
More information about the llvm-commits
mailing list