Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions gef.py
Original file line number Diff line number Diff line change
Expand Up @@ -6981,6 +6981,11 @@ def tcachebin(self, tcache_base: int, i: int) -> tuple[GlibcTcacheChunk | None,
count = u16(gef.memory.read(tcache_base + tcache_count_size*i, 2))

chunk = dereference(tcache_base + tcache_count_size*self.TCACHE_MAX_BINS + i*gef.arch.ptrsize)

# Real heap chunk pointers are always ptrsize-aligned, so we check
# the alignment to prevent following invalid addresses.
if chunk and (int(chunk) & (gef.arch.ptrsize - 1)):
return None, count
chunk = GlibcTcacheChunk(int(chunk)) if chunk else None
return chunk, count

Expand Down
13 changes: 0 additions & 13 deletions tests/commands/heap.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
ERROR_INACTIVE_SESSION_MESSAGE,
debug_target,
findlines,
is_glibc_ge,
is_32b,
is_64b,
)
Expand All @@ -22,7 +21,6 @@ def setUp(self) -> None:
self._target = debug_target("heap")
return super().setUp()

@pytest.mark.skipif(is_glibc_ge(2, 43), reason="Skipped for glibc >= 2.43")
def test_cmd_heap_arenas(self):
gdb = self._gdb
cmd = "heap arenas"
Expand All @@ -34,7 +32,6 @@ def test_cmd_heap_arenas(self):
res = gdb.execute(cmd, to_string=True)
self.assertIn("Arena(base=", res)

@pytest.mark.skipif(is_glibc_ge(2, 43), reason="Skipped for glibc >= 2.43")
def test_cmd_heap_set_arena(self):
gdb = self._gdb
cmd = "heap set-arena &main_arena"
Expand Down Expand Up @@ -70,7 +67,6 @@ def test_cmd_heap_chunk_with_number(self):
chunklines = findlines("Chunk(addr=", res)
self.assertEqual(len(chunklines), 2)

@pytest.mark.skipif(is_glibc_ge(2, 43), reason="Skipped for glibc >= 2.43")
def test_cmd_heap_chunks(self):
gdb = self._gdb
cmd = "heap chunks"
Expand All @@ -95,7 +91,6 @@ def test_cmd_heap_chunks_summary(self):
self.assertIn("== Chunk distribution by size", res)
self.assertIn("== Chunk distribution by flag", res)

@pytest.mark.skipif(is_glibc_ge(2, 43), reason="Skipped for glibc >= 2.43")
def test_cmd_heap_chunks_min_size_filter(self):
gdb = self._gdb
self.assertEqual(
Expand Down Expand Up @@ -153,7 +148,6 @@ def setUp(self) -> None:
self._target = debug_target("heap-non-main")
return super().setUp()

@pytest.mark.skipif(is_glibc_ge(2, 43), reason="Skipped for glibc >= 2.43")
def test_cmd_heap_chunks(self):
gdb = self._gdb
cmd = "heap chunks"
Expand All @@ -175,7 +169,6 @@ def test_cmd_heap_chunks(self):
# make sure that the chunks of each arena are distinct
self.assertNotEqual(chunks, non_main_chunks)

@pytest.mark.skipif(is_glibc_ge(2, 43), reason="Skipped for glibc >= 2.43")
def test_cmd_heap_bins_non_main(self):
gdb = self._gdb
gef = self._gef
Expand All @@ -188,7 +181,6 @@ def test_cmd_heap_bins_non_main(self):
self.assertIn("size=0x20", res)

@pytest.mark.skipif(ARCH not in ("i686", "x86_64",), reason=f"Skipped for {ARCH}")
@pytest.mark.skipif(is_glibc_ge(2, 42), reason="Skipped for glibc >= 2.42")
def test_cmd_heap_bins_tcache(self):
gdb = self._gdb
gdb.execute("run")
Expand All @@ -210,7 +202,6 @@ def setUp(self) -> None:
self._target = debug_target("heap-multiple-heaps")
return super().setUp()

@pytest.mark.skipif(is_glibc_ge(2, 43), reason="Skipped for glibc >= 2.43")
def test_cmd_heap_chunks_mult_heaps(self):
gdb = self._gdb

Expand Down Expand Up @@ -268,7 +259,6 @@ def setUp(self) -> None:
self.expected_unsorted_bin_size = 0x430 if ARCH == "i686" or is_64b() else 0x428
return super().setUp()

@pytest.mark.skipif(is_glibc_ge(2, 43), reason="Skipped for glibc >= 2.43")
def test_cmd_heap_bins_large(self):
gdb = self._gdb
gdb.execute("run")
Expand All @@ -278,7 +268,6 @@ def test_cmd_heap_bins_large(self):
self.assertIn("Chunk(addr=", res)
self.assertIn(f"size={self.expected_large_bin_size:#x}", res)

@pytest.mark.skipif(is_glibc_ge(2, 43), reason="Skipped for glibc >= 2.43")
def test_cmd_heap_bins_small(self):
gdb = self._gdb
cmd = "heap bins small"
Expand All @@ -289,7 +278,6 @@ def test_cmd_heap_bins_small(self):
self.assertIn("Chunk(addr=", res)
self.assertIn(f"size={self.expected_small_bin_size:#x}", res)

@pytest.mark.skipif(is_glibc_ge(2, 43), reason="Skipped for glibc >= 2.43")
def test_cmd_heap_bins_unsorted(self):
gdb = self._gdb
gdb.execute("run")
Expand All @@ -307,7 +295,6 @@ def setUp(self) -> None:
return super().setUp()

@pytest.mark.skipif(ARCH not in ("i686", "x86_64"), reason=f"Skipped for {ARCH}")
@pytest.mark.skipif(is_glibc_ge(2, 42), reason="Skipped for glibc >= 2.42")
def test_cmd_heap_bins_tcache_all(self):
gdb = self._gdb
gdb.execute("run")
Expand Down
Loading