Bug 466762 - Add redirs for C23 free_sized() and free_aligned_sized()
[valgrind.git] / memcheck / tests / pdb-realloc.c
blob810f7b2575c49cd37352517e75432f43431c1515
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 = 0;
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 __asm__ __volatile__ ("" :: "r"(t));
31 return 0;