From b6917b42f40073d5adc156f5d56e55c31fa98aba Mon Sep 17 00:00:00 2001 From: Sagar Thakur Date: Wed, 24 Feb 2016 13:48:14 +0000 Subject: [PATCH] [MSAN] Fix memcmp_test on MIPS Summary: As per the test the 4th element of both arrays are not initialized and hence will contain garbage values. Memcmp returns the difference between the garbage values of the 4th element which will be different on every run of the test. And since the return value of memcmp is returned from main, we are getting random exit code every time. Reviewers: kcc, eugenis Subscribers: mohit.bhakkad, jaydeep, llvm-commits Differential: http://reviews.llvm.org/D17534 llvm-svn: 261739 --- compiler-rt/test/msan/memcmp_test.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler-rt/test/msan/memcmp_test.cc b/compiler-rt/test/msan/memcmp_test.cc index 95228eb..5ade58a 100644 --- a/compiler-rt/test/msan/memcmp_test.cc +++ b/compiler-rt/test/msan/memcmp_test.cc @@ -3,13 +3,16 @@ // RUN: MSAN_OPTIONS=intercept_memcmp=0 %run %t #include +#include int main(int argc, char **argv) { char a1[4]; char a2[4]; for (int i = 0; i < argc * 3; i++) a2[i] = a1[i] = i; int res = memcmp(a1, a2, 4); - return res; + if (!res) + printf("equals"); + return 0; // CHECK: Uninitialized bytes in __interceptor_memcmp at offset 3 // CHECK: MemorySanitizer: use-of-uninitialized-value } -- 2.7.4