From 2679aea16091703dc1d0e4a8b07f45ce0bdb0bca Mon Sep 17 00:00:00 2001 From: Philippe Waroquiers Date: Tue, 12 Jul 2016 20:48:31 +0000 Subject: [PATCH] Regression test for n-i-bz amd64: memcheck false positive with shr %edx 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 | 2 +- memcheck/tests/amd64/Makefile.am | 2 + memcheck/tests/amd64/shr_edx.c | 54 +++++++++++++++++++++++++ memcheck/tests/amd64/shr_edx.stderr.exp | 0 memcheck/tests/amd64/shr_edx.stdout.exp | 4 ++ memcheck/tests/amd64/shr_edx.vgtest | 2 + 6 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 memcheck/tests/amd64/shr_edx.c create mode 100644 memcheck/tests/amd64/shr_edx.stderr.exp create mode 100644 memcheck/tests/amd64/shr_edx.stdout.exp create mode 100644 memcheck/tests/amd64/shr_edx.vgtest diff --git a/NEWS b/NEWS index b85b786fa2..68f5ab7730 100644 --- 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) diff --git a/memcheck/tests/amd64/Makefile.am b/memcheck/tests/amd64/Makefile.am index dc48f417c6..a6c80680e6 100644 --- a/memcheck/tests/amd64/Makefile.am +++ b/memcheck/tests/amd64/Makefile.am @@ -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 index 0000000000..f8746afff5 --- /dev/null +++ b/memcheck/tests/amd64/shr_edx.c @@ -0,0 +1,54 @@ +#include +#include +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 index 0000000000..e69de29bb2 diff --git a/memcheck/tests/amd64/shr_edx.stdout.exp b/memcheck/tests/amd64/shr_edx.stdout.exp new file mode 100644 index 0000000000..13ddbafc01 --- /dev/null +++ b/memcheck/tests/amd64/shr_edx.stdout.exp @@ -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 index 0000000000..3d783ef440 --- /dev/null +++ b/memcheck/tests/amd64/shr_edx.vgtest @@ -0,0 +1,2 @@ +prog: shr_edx +vgopts: -q -- 2.47.2