xen: Infratructure for XEN_TMEM_* hypercalls
[valgrind.git] / memcheck / tests / pdb-realloc.c
blobfbb13c7414603365c72c39b8c587000b03f92894
1 // This test-case exposes a bug that was present in the compressed V bit
2 // handling for a while. The problem was that when
3 // copy_address_range_state() copied a VA_BITS2_OTHER value, it failed to
4 // also copy the corresponding entry in the sec-V-bits table. Then later on
5 // when we searched for the sec-V-bits entry for the copied-to location, it
6 // failed to find it:
7 //
8 // Memcheck: mc_main.c:766 (get_sec_vbits8): Assertion 'n' failed.
9 // Memcheck: get_sec_vbits8: no node for address 0x4017440 (0x4017441)
11 #include <stdlib.h>
13 int main(void)
15 int i, t;
16 char* x = malloc(1000);
18 // Write some PDBs (partially defined bytes)
19 for (i = 0; i < 1000; i++)
20 x[i] &= (i & 0xff);
22 // realloc them, invoking copy_address_range_state()
23 x = realloc(x, 10000);
25 // Read the PDBs -- this caused a sec-V-bits lookup failure.
26 for (i = 0; i < 1000; i++)
27 t += x[i];
29 return 0;