|
From: Jeremy F. <je...@go...> - 2005-02-23 02:33:34
|
CVS commit by fitzhardinge:
Make the leak-checker handle references to 0-byte allocations properly.
BUGS:99923
M +10 -5 mac_leakcheck.c 1.18
--- valgrind/memcheck/mac_leakcheck.c #1.17:1.18
@@ -201,5 +201,5 @@ Int find_shadow_for_OLD ( Addr pt
PROF_EVENT(71);
a_lo = shadows[i]->data;
- a_hi = ((Addr)shadows[i]->data) + shadows[i]->size - 1;
+ a_hi = ((Addr)shadows[i]->data) + shadows[i]->size;
if (a_lo <= ptr && ptr <= a_hi)
return i;
@@ -227,5 +227,5 @@ Int find_shadow_for ( Addr ptr,
mid = (lo + hi) / 2;
a_mid_lo = shadows[mid]->data;
- a_mid_hi = shadows[mid]->data + shadows[mid]->size - 1;
+ a_mid_hi = shadows[mid]->data + shadows[mid]->size;
if (ptr < a_mid_lo) {
@@ -277,16 +277,21 @@ void vg_detect_memory_leaks_notify_addr
line.
*/
- if (!VG_(is_client_addr)(a)) return;
+ if (!VG_(is_client_addr)(a))
+ return;
/* OK, let's get on and do something Useful for a change. */
ptr = (Addr)word_at_a;
+ if (0)
+ VG_(printf)("notify %p -> %x; min=%p max=%p\n", a, word_at_a,
+ lc_min_mallocd_addr, lc_max_mallocd_addr);
if (ptr >= lc_min_mallocd_addr && ptr <= lc_max_mallocd_addr) {
/* Might be legitimate; we'll have to investigate further. */
sh_no = find_shadow_for ( ptr, lc_shadows, lc_n_shadows );
+ if (0) VG_(printf)("find_shadow_for(%p) -> %d\n", ptr, sh_no);
if (sh_no != -1) {
/* Found a block at/into which ptr points. */
sk_assert(sh_no >= 0 && sh_no < lc_n_shadows);
- sk_assert(ptr < lc_shadows[sh_no]->data + lc_shadows[sh_no]->size);
+ sk_assert(ptr <= lc_shadows[sh_no]->data + lc_shadows[sh_no]->size);
/* Decide whether Proper-ly or Interior-ly reached. */
if (ptr == lc_shadows[sh_no]->data) {
@@ -391,5 +396,5 @@ void MAC_(do_detect_memory_leaks) (
lc_min_mallocd_addr = lc_shadows[0]->data;
lc_max_mallocd_addr = lc_shadows[lc_n_shadows-1]->data
- + lc_shadows[lc_n_shadows-1]->size - 1;
+ + lc_shadows[lc_n_shadows-1]->size;
lc_reachedness = VG_(malloc)( lc_n_shadows * sizeof(Reachedness) );
|