From dfa5595628651f55bda7437c80631d596c8b61f9 Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Tue, 16 Jul 2013 14:26:20 -0700 Subject: [PATCH] rt: Diagnose bad alloc index in release_alloc with RUSTRT_TRACK_ALLOCATIONS --- src/rt/memory_region.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/rt/memory_region.cpp b/src/rt/memory_region.cpp index f3406712cb01..15cac3ef79be 100644 --- a/src/rt/memory_region.cpp +++ b/src/rt/memory_region.cpp @@ -203,6 +203,11 @@ memory_region::release_alloc(void *mem) { # if RUSTRT_TRACK_ALLOCATIONS >= 2 if (_synchronized) { _lock.lock(); } + if (((size_t) alloc->index) >= _allocation_list.size()) { + printf("free: ptr 0x%" PRIxPTR " (%s) index %d is beyond allocation_list of size %zu\n", + (uintptr_t) get_data(alloc), alloc->tag, alloc->index, _allocation_list.size()); + assert(false && "index beyond allocation_list"); + } if (_allocation_list[alloc->index] != alloc) { printf("free: ptr 0x%" PRIxPTR " (%s) is not in allocation_list\n", (uintptr_t) get_data(alloc), alloc->tag);