|
From: <sv...@va...> - 2008-04-29 16:49:36
|
Author: sewardj
Date: 2008-04-29 17:49:35 +0100 (Tue, 29 Apr 2008)
New Revision: 7957
Log:
Add some tests for origin tracking. These are marginally modified
versions of the tests in Nick Nethercote's
origin-tracking-by-piggybacking branch (branches/ORIGIN_TRACKING).
Added:
branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin1-yes.c
branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin1-yes.stderr.exp
branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin1-yes.stdout.exp
branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin1-yes.vgtest
branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin2-not-quite.c
branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin2-not-quite.stderr.exp
branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin2-not-quite.stdout.exp
branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin2-not-quite.vgtest
branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin3-no.c
branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin3-no.stderr.exp
branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin3-no.stdout.exp
branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin3-no.vgtest
branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin4-many.c
branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin4-many.stderr.exp-glibc25-amd64
branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin4-many.stderr.exp-glibc25-x86
branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin4-many.stdout.exp
branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin4-many.vgtest
Modified:
branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/Makefile.am
Modified: branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/Makefile.am
===================================================================
--- branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/Makefile.am 2008-04-29 11:53:31 UTC (rev 7956)
+++ branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/Makefile.am 2008-04-29 16:49:35 UTC (rev 7957)
@@ -94,8 +94,17 @@
new_override.stderr.exp new_override.stdout.exp new_override.vgtest \
noisy_child.vgtest noisy_child.stderr.exp noisy_child.stdout.exp \
null_socket.stderr.exp null_socket.vgtest \
+ origin1-yes.vgtest origin1-yes.stdout.exp \
+ origin1-yes.stderr.exp \
+ origin2-not-quite.vgtest origin2-not-quite.stdout.exp \
+ origin2-not-quite.stderr.exp \
+ origin3-no.vgtest origin3-no.stdout.exp \
+ origin3-no.stderr.exp \
+ origin4-many.vgtest origin4-many.stdout.exp \
+ origin4-many.stderr.exp-x86-glibc25 \
+ origin4-many.stderr.exp-amd64-glibc25 \
+ oset_test.stderr.exp oset_test.stdout.exp oset_test.vgtest \
overlap.stderr.exp overlap.stdout.exp overlap.vgtest \
- oset_test.stderr.exp oset_test.stdout.exp oset_test.vgtest \
partiallydefinedeq.vgtest partiallydefinedeq.stderr.exp \
partiallydefinedeq.stderr.exp2 \
partiallydefinedeq.stdout.exp \
@@ -177,7 +186,9 @@
memalign_test memalign2 memcmptest mempool mmaptest \
nanoleak nanoleak2 new_nothrow \
noisy_child \
- null_socket oset_test overlap \
+ null_socket oset_test \
+ origin1-yes origin2-not-quite origin3-no origin4-many \
+ overlap \
partiallydefinedeq \
partial_load pdb-realloc pdb-realloc2 \
pipe pointer-trace \
@@ -229,6 +240,8 @@
varinfo4_CFLAGS = $(AM_FLAG_M3264_PRI) $(AM_CFLAGS) -O -g
varinfo5_CFLAGS = $(AM_FLAG_M3264_PRI) $(AM_CFLAGS) -O -g
varinfo6_CFLAGS = $(AM_FLAG_M3264_PRI) $(AM_CFLAGS) -O -g
+# This requires optimisation in order to get just one resulting error
+origin4_many_CFLAGS = $(AM_FLAG_M3264_PRI) $(AM_CFLAGS) -O -g
# C++ tests
mismatches_SOURCES = mismatches.cpp
Added: branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin1-yes.c
===================================================================
--- branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin1-yes.c (rev 0)
+++ branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin1-yes.c 2008-04-29 16:49:35 UTC (rev 7957)
@@ -0,0 +1,135 @@
+
+/* This test case was originally written by Nicholas Nethercote. */
+
+// This test covers all the different sources of values, both defined and
+// undefined. It only involves undefined condition errors.
+//
+// Nb: a stack frame is allocated when a signal is delivered. But it
+// immediately get written with stuff, so there's no significant possibility
+// of undefined values originating there. So we ignore it. (On platforms
+// like AMD64 that have a redzone just beyond the stack pointer there is a
+// possibility, but it's so slim we ignore it.)
+
+#include <stdio.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include "../memcheck.h"
+
+int x = 0;
+
+int main(void)
+{
+ assert(1 == sizeof(char));
+ assert(2 == sizeof(short));
+ assert(4 == sizeof(int));
+ assert(8 == sizeof(long long));
+
+ //------------------------------------------------------------------------
+ // Sources of undefined values
+ //------------------------------------------------------------------------
+
+ // Stack, 32-bit
+ {
+ volatile int undef_stack_int;
+ fprintf(stderr, "\nUndef 1 of 8 (stack, 32 bit)\n");
+ x += (undef_stack_int == 0x12345678 ? 10 : 21);
+ }
+
+ // Stack, 32-bit, recently modified. Nb: we have to do the register
+ // mucking about to make sure that the modification isn't fenced by a
+ // store/load pair and thus not seen (see origin-not-quite.c).
+ {
+ volatile int undef_stack_int;
+ register int modified_undef_stack_int;
+ fprintf(stderr, "\nUndef 2 of 8 (stack, 32 bit)\n");
+ modified_undef_stack_int = undef_stack_int;
+ modified_undef_stack_int++;
+ x += (modified_undef_stack_int == 0x1234 ? 11 : 22);
+ }
+
+ // Stack, 64-bit. XXX: gets reported with two identical origins.
+ {
+ volatile long long undef_stack_longlong;
+ fprintf(stderr, "\nUndef 3 of 8 (stack, 64 bit)\n");
+ x += (undef_stack_longlong == 0x1234567812345678LL ? 11 : 22);
+ }
+
+ // Malloc block, uninitialised, 32-bit
+ {
+ int* ptr_to_undef_malloc_int = malloc(sizeof(int));
+ int undef_malloc_int = *ptr_to_undef_malloc_int;
+ fprintf(stderr, "\nUndef 4 of 8 (mallocd, 32-bit)\n");
+ x += (undef_malloc_int == 0x12345678 ? 12 : 23);
+ }
+
+ // Realloc block, uninitialised
+ {
+ int* ptr_to_undef_malloc_int2 = malloc(sizeof(int));
+ // Allocate a big chunk to ensure that a new block is allocated.
+ int* ptr_to_undef_realloc_int = realloc(ptr_to_undef_malloc_int2, 4096);
+ // Have to move past the first 4 bytes, which were copied from the
+ // malloc'd block.
+ int undef_realloc_int = *(ptr_to_undef_realloc_int+1);
+ fprintf(stderr, "\nUndef 5 of 8 (realloc)\n");
+ x += (undef_realloc_int == 0x12345678 ? 13 : 24);
+ }
+
+ // Custom-allocated block, non-zeroed
+ {
+ int undef_custom_alloc_int;
+ VALGRIND_MALLOCLIKE_BLOCK(&undef_custom_alloc_int, sizeof(int),
+ /*rzB*/0, /*is_zeroed*/0);
+ fprintf(stderr, "\nUndef 6 of 8 (MALLOCLIKE_BLOCK)\n");
+ x += (undef_custom_alloc_int == 0x12345678 ? 14 : 25);
+ }
+
+ // Heap segment (brk), uninitialised
+ {
+ int* ptr_to_new_brk_limit = sbrk(4096);
+ int undef_brk_int = *ptr_to_new_brk_limit;
+ fprintf(stderr, "\nUndef 7 of 8 (brk)\n");
+ x += (undef_brk_int == 0x12345678 ? 15 : 26);
+ }
+
+ // User block, marked as undefined
+ {
+ int undef_user_int = 0;
+ VALGRIND_MAKE_MEM_UNDEFINED(&undef_user_int, sizeof(int));
+ fprintf(stderr, "\nUndef 8 of 8 (MAKE_MEM_UNDEFINED)\n");
+ x += (undef_user_int == 0x12345678 ? 16 : 27);
+ }
+
+ //------------------------------------------------------------------------
+ // Sources of defined values
+ //------------------------------------------------------------------------
+
+ // Heap block (calloc), initialised
+ {
+ int* ptr_to_def_calloc_int = calloc(1, sizeof(int));
+ int def_calloc_int = *ptr_to_def_calloc_int;
+ fprintf(stderr, "\nDef 1 of 3\n");
+ x += (def_calloc_int == 0x12345678 ? 17 : 28);
+ }
+
+ // Custom-allocated block, non-zeroed
+ {
+ int def_custom_alloc_int = 0;
+ fprintf(stderr, "\nDef 2 of 3\n");
+ VALGRIND_MALLOCLIKE_BLOCK(&def_custom_alloc_int, sizeof(int),
+ /*rzB*/0, /*is_zeroed*/1);
+ x += (def_custom_alloc_int == 0x12345678 ? 18 : 29);
+ }
+
+ // mmap block, initialised
+ {
+ int* ptr_to_def_mmap_int =
+ mmap(0, 4096, PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+ int def_mmap_int = *ptr_to_def_mmap_int;
+ fprintf(stderr, "\nDef 3 of 3\n");
+ x += (def_mmap_int == 0x12345678 ? 19 : 30);
+ }
+
+ return x;
+}
Added: branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin1-yes.stderr.exp
===================================================================
--- branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin1-yes.stderr.exp (rev 0)
+++ branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin1-yes.stderr.exp 2008-04-29 16:49:35 UTC (rev 7957)
@@ -0,0 +1,65 @@
+
+Undef 1 of 8 (stack, 32 bit)
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: main (origin1-yes.c:37)
+ Uninitialised value was created by a stack allocation
+ at 0x........: main (origin1-yes.c:23)
+
+Undef 2 of 8 (stack, 32 bit)
+
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: main (origin1-yes.c:49)
+ Uninitialised value was created by a stack allocation
+ at 0x........: main (origin1-yes.c:23)
+
+Undef 3 of 8 (stack, 64 bit)
+
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: main (origin1-yes.c:56)
+ Uninitialised value was created by a stack allocation
+ at 0x........: main (origin1-yes.c:23)
+
+Undef 4 of 8 (mallocd, 32-bit)
+
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: main (origin1-yes.c:64)
+ Uninitialised value was created by a heap allocation
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ by 0x........: main (origin1-yes.c:61)
+
+Undef 5 of 8 (realloc)
+
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: main (origin1-yes.c:76)
+ Uninitialised value was created by a heap allocation
+ at 0x........: realloc (vg_replace_malloc.c:...)
+ by 0x........: main (origin1-yes.c:71)
+
+Undef 6 of 8 (MALLOCLIKE_BLOCK)
+
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: main (origin1-yes.c:85)
+ Uninitialised value was created by a heap allocation
+ at 0x........: main (origin1-yes.c:82)
+
+Undef 7 of 8 (brk)
+
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: main (origin1-yes.c:93)
+ Uninitialised value was created
+ at 0x........: brk (in /...libc...)
+ by 0x........: ...
+ by 0x........: main (origin1-yes.c:90)
+
+Undef 8 of 8 (MAKE_MEM_UNDEFINED)
+
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: main (origin1-yes.c:101)
+ Uninitialised value was created by a client request
+ at 0x........: main (origin1-yes.c:99)
+
+Def 1 of 3
+
+Def 2 of 3
+
+Def 3 of 3
Added: branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin1-yes.stdout.exp
===================================================================
Added: branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin1-yes.vgtest
===================================================================
--- branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin1-yes.vgtest (rev 0)
+++ branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin1-yes.vgtest 2008-04-29 16:49:35 UTC (rev 7957)
@@ -0,0 +1,2 @@
+prog: origin1-yes
+vgopts: -q --track-origins=yes
Added: branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin2-not-quite.c
===================================================================
--- branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin2-not-quite.c (rev 0)
+++ branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin2-not-quite.c 2008-04-29 16:49:35 UTC (rev 7957)
@@ -0,0 +1,49 @@
+
+/* This test case was originally written by Nicholas Nethercote. */
+
+// This test demonstrates some cases that the piggybacking algorithm
+// but conceivably might, with more modifications. The instrumentation
+// based algorithm handles them ok, though.
+
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+int x = 0;
+
+typedef long long Long;
+
+int main(void)
+{
+ assert(4 == sizeof(int));
+ assert(8 == sizeof(Long));
+
+ // 64-bit undefined double.
+ {
+ double* ptr_to_undef_double = malloc(sizeof(double));
+ double undef_double = *ptr_to_undef_double;
+ fprintf(stderr, "\nUndef 1 of 3 (64-bit FP)\n");
+ x += (undef_double < (double)123.45 ? 12 : 23);
+ }
+
+ // 32-bit undefined float.
+ {
+ float* ptr_to_undef_float = malloc(sizeof(float));
+ float undef_float = *ptr_to_undef_float;
+ fprintf(stderr, "\nUndef 2 of 3 (32-bit FP)\n");
+ x += (undef_float < (float)234.56 ? 13 : 24);
+ }
+
+ // Stack, 32-bit, recently modified.
+ // Problem here is that we don't chase backwards through loads and
+ // stores. Ie. the variable is stored after it's been modified, then
+ // loaded again, so we don't see the unmodified version.
+ {
+ int modified_undef_stack_int;
+ modified_undef_stack_int++;
+ fprintf(stderr, "\nUndef 3 of 3 (int)\n");
+ x += (modified_undef_stack_int == 0x1234 ? 11 : 22);
+ }
+
+ return x;
+}
Added: branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin2-not-quite.stderr.exp
===================================================================
--- branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin2-not-quite.stderr.exp (rev 0)
+++ branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin2-not-quite.stderr.exp 2008-04-29 16:49:35 UTC (rev 7957)
@@ -0,0 +1,22 @@
+
+Undef 1 of 3 (64-bit FP)
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: main (origin2-not-quite.c:26)
+ Uninitialised value was created by a heap allocation
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ by 0x........: main (origin2-not-quite.c:23)
+
+Undef 2 of 3 (32-bit FP)
+
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: main (origin2-not-quite.c:34)
+ Uninitialised value was created by a heap allocation
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ by 0x........: main (origin2-not-quite.c:31)
+
+Undef 3 of 3 (int)
+
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: main (origin2-not-quite.c:45)
+ Uninitialised value was created by a stack allocation
+ at 0x........: main (origin2-not-quite.c:17)
Added: branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin2-not-quite.stdout.exp
===================================================================
Added: branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin2-not-quite.vgtest
===================================================================
--- branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin2-not-quite.vgtest (rev 0)
+++ branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin2-not-quite.vgtest 2008-04-29 16:49:35 UTC (rev 7957)
@@ -0,0 +1,2 @@
+prog: origin2-not-quite
+vgopts: -q --track-origins=yes
Added: branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin3-no.c
===================================================================
--- branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin3-no.c (rev 0)
+++ branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin3-no.c 2008-04-29 16:49:35 UTC (rev 7957)
@@ -0,0 +1,86 @@
+
+/* This test case was originally written by Nicholas Nethercote. */
+
+// This test demonstrates cases the piggybacking algorithm cannot handle,
+// but which are handled ok by the instrumentation based algorithm.
+
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "../memcheck.h"
+
+int x = 0;
+
+int main(void)
+{
+ assert(4 == sizeof(int));
+
+ // 8-bit undefined value. When compared it's loaded from memory, so will
+ // never work.
+ {
+ char* ptr_to_undef_char = malloc(sizeof(char));
+ char undef_char = *ptr_to_undef_char;
+ fprintf(stderr, "\nUndef 1 of 8 (8 bit undef)\n");
+ x += (undef_char == 0x12 ? 11 : 22);
+ }
+
+ // Stack, 8-bit from (recently) 32-bit. But the load only loads 8-bits
+ // of the value, so it'll never work.
+ {
+ int undef_stack_int;
+ register char undef_stack_char = (char)undef_stack_int;
+ fprintf(stderr, "\nUndef 2 of 8 (8 bits of 32 undef)\n");
+ x += (undef_stack_char == 0x12 ? 11 : 22);
+ }
+
+ // 32-bit undefined value. This one is identified, and is here for
+ // sanity-checking.
+ {
+ int* ptr_to_undef_int = malloc(sizeof(int));
+ int undef_int = *ptr_to_undef_int;
+ fprintf(stderr, "\nUndef 3 of 8 (32 bit undef)\n");
+ x += (undef_int == 0x12345678 ? 13 : 24);
+ }
+
+ // Unaligned 32-bit value.
+ {
+ int* ptr_to_undef_int = malloc(sizeof(int) + 1);
+ int undef_unaligned_int = *(int*)((long)ptr_to_undef_int + 1);
+ fprintf(stderr, "\nUndef 4 of 8 (32 bit undef, unaligned)\n");
+ x += (undef_unaligned_int == 0x12345678 ? 14 : 25);
+ }
+
+ // Modified 32-bit value.
+ {
+ int* ptr_to_undef_int3 = malloc(sizeof(int));
+ int modified_undef_int = *ptr_to_undef_int3;
+ fprintf(stderr, "\nUndef 5 of 8 (32 bit undef, modified)\n");
+ modified_undef_int++;
+ x += (modified_undef_int == 0x12345678 ? 15 : 26);
+ }
+
+ // Uninitialised 32-bit value (middle of 3) is made undefined in two
+ // unaligned pieces:
+ // |....|....|....| three 4-byte integers
+ // XXXX-YY first MAKE_MEM_UNDEFINED
+ // YY-XXXX second MAKE_MEM_UNDEFINED
+ // Because the YY parts don't get marked (they're not 32-bit and aligned)
+ // the middle byte keeps its original value, which is zero (from calloc).
+ // So even though it's been marked as undefined, it doesn't have an
+ // origin-tracking value and so cannot be identified. We also check the
+ // first and third ints (which are identified) for sanity-checking.
+ {
+ int* ptr_to_3_undef_ints = calloc(3, sizeof(int));
+ int* ptr_to_middle = (int*)((long)ptr_to_3_undef_ints + 6);
+ VALGRIND_MAKE_MEM_UNDEFINED(ptr_to_3_undef_ints, 6);
+ VALGRIND_MAKE_MEM_UNDEFINED(ptr_to_middle, 6);
+ fprintf(stderr, "\nUndef 6 of 8 (32 bit undef, unaligned, strange, #1)\n");
+ x += (*(ptr_to_3_undef_ints + 0) == 0x12345678 ? 16 : 27);
+ fprintf(stderr, "\nUndef 7 of 8 (32 bit undef, unaligned, strange, #2)\n");
+ x += (*(ptr_to_3_undef_ints + 1) == 0x12345678 ? 17 : 28);
+ fprintf(stderr, "\nUndef 8 of 8 (32 bit undef, unaligned, strange, #3)\n");
+ x += (*(ptr_to_3_undef_ints + 2) == 0x12345678 ? 18 : 29);
+ }
+
+ return x;
+}
Added: branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin3-no.stderr.exp
===================================================================
--- branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin3-no.stderr.exp (rev 0)
+++ branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin3-no.stderr.exp 2008-04-29 16:49:35 UTC (rev 7957)
@@ -0,0 +1,59 @@
+
+Undef 1 of 8 (8 bit undef)
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: main (origin3-no.c:24)
+ Uninitialised value was created by a heap allocation
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ by 0x........: main (origin3-no.c:21)
+
+Undef 2 of 8 (8 bits of 32 undef)
+
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: main (origin3-no.c:33)
+ Uninitialised value was created by a stack allocation
+ at 0x........: main (origin3-no.c:15)
+
+Undef 3 of 8 (32 bit undef)
+
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: main (origin3-no.c:42)
+ Uninitialised value was created by a heap allocation
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ by 0x........: main (origin3-no.c:39)
+
+Undef 4 of 8 (32 bit undef, unaligned)
+
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: main (origin3-no.c:50)
+ Uninitialised value was created by a heap allocation
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ by 0x........: main (origin3-no.c:47)
+
+Undef 5 of 8 (32 bit undef, modified)
+
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: main (origin3-no.c:59)
+ Uninitialised value was created by a heap allocation
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ by 0x........: main (origin3-no.c:55)
+
+Undef 6 of 8 (32 bit undef, unaligned, strange, #1)
+
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: main (origin3-no.c:78)
+ Uninitialised value was created by a client request
+ at 0x........: main (origin3-no.c:75)
+
+Undef 7 of 8 (32 bit undef, unaligned, strange, #2)
+
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: main (origin3-no.c:80)
+ Uninitialised value was created by a client request
+ at 0x........: main (origin3-no.c:76)
+
+Undef 8 of 8 (32 bit undef, unaligned, strange, #3)
+
+Conditional jump or move depends on uninitialised value(s)
+ at 0x........: main (origin3-no.c:82)
+ Uninitialised value was created by a client request
+ at 0x........: main (origin3-no.c:76)
Added: branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin3-no.stdout.exp
===================================================================
Added: branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin3-no.vgtest
===================================================================
--- branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin3-no.vgtest (rev 0)
+++ branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin3-no.vgtest 2008-04-29 16:49:35 UTC (rev 7957)
@@ -0,0 +1,2 @@
+prog: origin3-no
+vgopts: -q --track-origins=yes
Added: branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin4-many.c
===================================================================
--- branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin4-many.c (rev 0)
+++ branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin4-many.c 2008-04-29 16:49:35 UTC (rev 7957)
@@ -0,0 +1,59 @@
+
+/* This test case was originally written by Nicholas Nethercote. */
+
+// (old comments)
+// This file tests how many possible origins can be tracked for a single
+// error.
+// XXX: other files don't need to do have multiple origins for errors now,
+// thanks to this test...
+// (end of old comments)
+
+/* When compiled -O, this produces an executable which reports a
+ single uninitialised value error, on the value handed to the exit()
+ system call. Fair enough.
+
+ An important question is: which of the origins is reported in the
+ error? Well, considering that (1) m_execontext allocates ECUs
+ (origin tags, basically) in increasing order, and (2) memcheck's
+ instrumentation for dealing with two uninitialised sources simply
+ involves 'max'-ing the otags, we expect the origin to be attributed
+ to the last of the 8 mallocs, that is, to p_ui8.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+
+static int x = 0;
+
+int main(void)
+{
+ // Do them separately rather than all in one array so they all have
+ // different origins.
+ int* p_ui1 = malloc(sizeof(int));
+ int* p_ui2 = malloc(sizeof(int));
+ int* p_ui3 = malloc(sizeof(int));
+ int* p_ui4 = malloc(sizeof(int));
+ int* p_ui5 = malloc(sizeof(int));
+ int* p_ui6 = malloc(sizeof(int));
+ int* p_ui7 = malloc(sizeof(int));
+ int* p_ui8 = malloc(sizeof(int));
+ int ui1 = *p_ui1;
+ int ui2 = *p_ui2;
+ int ui3 = *p_ui3;
+ int ui4 = *p_ui4;
+ int ui5 = *p_ui5;
+ int ui6 = *p_ui6;
+ int ui7 = *p_ui7;
+ int ui8 = *p_ui8;
+
+ x += (ui1 == 0x12345678 ? 12 : 23);
+ x += (ui1 +ui2 == 0x12345678 ? 13 : 24);
+ x += (ui1 +ui2 +ui3 == 0x12345678 ? 14 : 25);
+ x += (ui1 +ui2 +ui3 +ui4 == 0x12345678 ? 15 : 26);
+ x += (ui1 +ui2 +ui3 +ui4 +ui5 == 0x12345678 ? 16 : 27);
+ x += (ui1 +ui2 +ui3 +ui4 +ui5 +ui6 == 0x12345678 ? 17 : 28);
+ x += (ui1 +ui2 +ui3 +ui4 +ui5 +ui6 +ui7 == 0x12345678 ? 18 : 29);
+ x += (ui1 +ui2 +ui3 +ui4 +ui5 +ui6 +ui7 +ui8 == 0x12345678 ? 19 : 30);
+
+ return x & 1;
+}
Added: branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin4-many.stderr.exp-glibc25-amd64
===================================================================
--- branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin4-many.stderr.exp-glibc25-amd64 (rev 0)
+++ branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin4-many.stderr.exp-glibc25-amd64 2008-04-29 16:49:35 UTC (rev 7957)
@@ -0,0 +1,7 @@
+Syscall param exit_group(exit_code) contains uninitialised byte(s)
+ at 0x........: _Exit (in /...libc...)
+ by 0x........: ...
+ by 0x........: (below main) (in /...libc...)
+ Uninitialised value was created by a heap allocation
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ by 0x........: main (origin4-many.c:39)
Added: branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin4-many.stderr.exp-glibc25-x86
===================================================================
--- branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin4-many.stderr.exp-glibc25-x86 (rev 0)
+++ branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin4-many.stderr.exp-glibc25-x86 2008-04-29 16:49:35 UTC (rev 7957)
@@ -0,0 +1,6 @@
+Syscall param exit_group(exit_code) contains uninitialised byte(s)
+ at 0x........: _Exit (in /...libc...)
+ by 0x........: (below main) (in /...libc...)
+ Uninitialised value was created by a heap allocation
+ at 0x........: malloc (vg_replace_malloc.c:...)
+ by 0x........: main (origin4-many.c:39)
Added: branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin4-many.stdout.exp
===================================================================
Added: branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin4-many.vgtest
===================================================================
--- branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin4-many.vgtest (rev 0)
+++ branches/OTRACK_BY_INSTRUMENTATION/memcheck/tests/origin4-many.vgtest 2008-04-29 16:49:35 UTC (rev 7957)
@@ -0,0 +1,2 @@
+prog: origin4-many
+vgopts: -q --track-origins=yes
|