Skip to content

Commit

Permalink
and a few improvment more
Browse files Browse the repository at this point in the history
  • Loading branch information
trolldbois committed Jan 9, 2016
1 parent 3ca6fd0 commit 7d1bd07
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions haystack/allocators/win32/winheap.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ def HEAP_get_virtual_allocated_blocks_list(self, record):
c_size = valloc.CommitSize
# requested
r_size = valloc.ReserveSize
if c_size == 0:
continue
vallocs.append((addr, c_size, r_size))
log.debug("vallocBlock: @0x%0.8x commit: 0x%x reserved: 0x%x" % (addr, c_size, r_size))
return vallocs
Expand Down
9 changes: 7 additions & 2 deletions haystack/allocators/win32/winheapwalker.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ def _set_chunk_lists(self):
# make the user allocated list
# lst = vallocs | chunks
chunks2 = set([(addr + sublen, size - sublen) for addr, size in chunks])
# chunks2 = set([(addr, size) for addr, size in chunks])
backend_allocs = vallocs | chunks2

# FIXME, we have a 0 size chunks.
self._check_sizes(backend_allocs)

# free_lists == free_chunks.
Expand All @@ -74,6 +76,7 @@ def _set_chunk_lists(self):
log.warning('Weird: len(free_chunks) != len(free_lists)')
else:
backend_free_chunks = set([(addr + sublen, size - sublen) for addr, size in free_chunks])
self._check_sizes(backend_free_chunks)

# frontend too
if self._heap.FrontEndHeapType == 0:
Expand All @@ -89,6 +92,8 @@ def _set_chunk_lists(self):
# points to chunk
front_allocs2 = set([(addr, size ) for addr, size in front_allocs])
front_free_chunks2 = set([(addr, size) for addr, size in front_free_chunks])
self._check_sizes(front_allocs2)
self._check_sizes(front_free_chunks2)

if self._heap.FrontEndHeapType == 1:
# LAL: reports vallocs and (_get_chunks-lal) as committed
Expand All @@ -106,9 +111,9 @@ def _set_chunk_lists(self):

def _check_sizes(self, chunks):
for addr, size in chunks:
if size < 0:
if size <= 0:
print self._heap_mapping
raise ValueError("chunk size cannot be negative")
raise ValueError("chunk size cannot be negative: 0x%x %d" % (addr,size))

def get_heap_children_mmaps(self):
""" use free lists to establish the hierarchy between mmaps"""
Expand Down

0 comments on commit 7d1bd07

Please sign in to comment.