File: pdb-realloc.c

package info (click to toggle)
valgrind 1%3A3.2.1-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 27,372 kB
  • ctags: 23,091
  • sloc: ansic: 192,648; xml: 10,723; sh: 4,750; perl: 4,023; makefile: 2,103; asm: 1,813; cpp: 140; haskell: 139
file content (31 lines) | stat: -rw-r--r-- 918 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// This test-case exposes a bug that was present in the compressed V bit
// handling for a while.  The problem was that when
// copy_address_range_state() copied a VA_BITS2_OTHER value, it failed to
// also copy the corresponding entry in the sec-V-bits table.  Then later on
// when we searched for the sec-V-bits entry for the copied-to location, it
// failed to find it:
//
//   Memcheck: mc_main.c:766 (get_sec_vbits8): Assertion 'n' failed.
//   Memcheck: get_sec_vbits8: no node for address 0x4017440 (0x4017441)

#include <stdlib.h>

int main(void)
{
   int i, t;
   char* x = malloc(1000);

   // Write some PDBs (partially defined bytes)
   for (i = 0; i < 1000; i++)
      x[i] &= (i & 0xff);

   // realloc them, invoking copy_address_range_state()
   x = realloc(x, 10000);

   // Read the PDBs -- this caused a sec-V-bits lookup failure.
   for (i = 0; i < 1000; i++)
      t += x[i];
   
   return 0;
}