]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Regression test for n-i-bz amd64: memcheck false positive with shr %edx
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Tue, 12 Jul 2016 20:48:31 +0000 (20:48 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Tue, 12 Jul 2016 20:48:31 +0000 (20:48 +0000)
Valgrind side : reproducer for the false positive memcheck
+ announce the fix (VEX side in next commit)

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15905

NEWS
memcheck/tests/amd64/Makefile.am
memcheck/tests/amd64/shr_edx.c [new file with mode: 0644]
memcheck/tests/amd64/shr_edx.stderr.exp [new file with mode: 0644]
memcheck/tests/amd64/shr_edx.stdout.exp [new file with mode: 0644]
memcheck/tests/amd64/shr_edx.vgtest [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index b85b786fa217394a058ca84232cbc2c4002d9554..68f5ab773015ca9e8838313e0dbc4d8edb939071 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -136,7 +136,7 @@ n-i-bz Fix ppoll_alarm exclusion on OS X
 n-i-bz Document brk segment limitation, reference manual in limit reached msg.
 n-i-bz Fix clobber list in none/tests/amd64/xacq_xrel.c [valgrind r15737]
 n-i-bz Bump allowed shift value for "add.w reg, sp, reg, lsl #N" [vex r3206]
-
+n-i-bz amd64: memcheck false positive with shr %edx
 
 
 Release 3.11.0 (22 September 2015)
index dc48f417c61f7ff0ac258b91c11698291ae8d60d..a6c80680e684af7464d6dd7be644d18b21109b1d 100644 (file)
@@ -30,6 +30,7 @@ EXTRA_DIST = \
        sh-mem-vec256-plo-yes.vgtest \
                sh-mem-vec256-plo-yes.stderr.exp \
                sh-mem-vec256-plo-yes.stdout.exp \
+       shr_edx.stderr.exp shr_edx.stdout.exp shr_edx.vgtest \
        sse_memory.stderr.exp sse_memory.stdout.exp sse_memory.vgtest \
        xor-undef-amd64.stderr.exp xor-undef-amd64.stdout.exp \
        xor-undef-amd64.vgtest \
@@ -43,6 +44,7 @@ check_PROGRAMS = \
        insn-bsfl \
        insn-pmovmskb \
        sh-mem-vec128 \
+       shr_edx \
        sse_memory \
        xor-undef-amd64
 if BUILD_AVX_TESTS
diff --git a/memcheck/tests/amd64/shr_edx.c b/memcheck/tests/amd64/shr_edx.c
new file mode 100644 (file)
index 0000000..f8746af
--- /dev/null
@@ -0,0 +1,54 @@
+#include <stdio.h>
+#include <stdlib.h>
+typedef unsigned long long int ULong;
+
+ULong data;
+ULong result;
+
+
+extern void shrl32_with_0x10 ( void );
+asm("\n"
+"shrl32_with_0x10:\n"
+"\tpushq %rdx\n"
+"\tmovq data, %rdx\n"
+"\tshr $0x10, %edx\n"
+"\tjne shrl32_with_0x10_jump\n"
+"\tshrl32_with_0x10_cont:\n"
+"\tmovq %rdx, result\n"
+"\tpopq %rdx\n"
+"\tret\n"
+"\tshrl32_with_0x10_jump:\n"
+"\tmov $0xdeaddead, %edx\n"
+"\tjmp shrl32_with_0x10_cont\n"
+);
+
+
+int main ( void )
+{
+  char *p;
+
+  printf("\nshrl 0x10 with unitialised bits\n");
+  ULong *notinitialised = malloc(sizeof(ULong)); // Not initialised data.
+  data = *notinitialised;
+  p = (char*) &data;
+  p[0] = 0x11;
+  // p[1] = 0x22;
+  p[2] = 0x33;
+  p[3] = 0x44;
+
+  shrl32_with_0x10();
+
+  printf("non zero jump on p[2..3] 0x%016llx\n", result);
+
+  data = *notinitialised;
+  p = (char*) &data;
+  p[0] = 0x00;
+  // p[1] = 0x00;
+  p[2] = 0x00;
+  p[3] = 0x00;
+
+  shrl32_with_0x10();
+
+  printf("zero jump on p[2..3] 0x%016llx\n", result);
+  return 0;
+}
diff --git a/memcheck/tests/amd64/shr_edx.stderr.exp b/memcheck/tests/amd64/shr_edx.stderr.exp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/memcheck/tests/amd64/shr_edx.stdout.exp b/memcheck/tests/amd64/shr_edx.stdout.exp
new file mode 100644 (file)
index 0000000..13ddbaf
--- /dev/null
@@ -0,0 +1,4 @@
+
+shrl 0x10 with unitialised bits
+non zero jump on p[2..3] 0x00000000deaddead
+zero jump on p[2..3] 0x0000000000000000
diff --git a/memcheck/tests/amd64/shr_edx.vgtest b/memcheck/tests/amd64/shr_edx.vgtest
new file mode 100644 (file)
index 0000000..3d783ef
--- /dev/null
@@ -0,0 +1,2 @@
+prog: shr_edx
+vgopts: -q