Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix chunk listing with tcache #16239

Merged
merged 2 commits into from
Mar 17, 2020
Merged
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
12 changes: 9 additions & 3 deletions libr/core/linux_heap_glibc.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ void GH(print_heap_chunk)(RCore *core) {
free (cnk);
}

static bool GH(is_arena) (RCore *core, GHT m_arena, GHT m_state) {
static bool GH(is_arena)(RCore *core, GHT m_arena, GHT m_state) {
if (m_arena == m_state) {
return true;
}
Expand Down Expand Up @@ -857,8 +857,14 @@ static void GH(print_heap_segment)(RCore *core, MallocState *main_arena,
if (m_arena == m_state) {
GH(get_brks) (core, &brk_start, &brk_end);
if (tcache) {
tcache_initial_brk = ((brk_start >> 12) << 12) + TC_HDR_SZ;
initial_brk = tcache_initial_brk + offset;
GH(RHeapChunk) *cnk = R_NEW0 (GH(RHeapChunk));
if (!cnk) {
return;
}
(void)r_io_read_at (core->io, brk_start, (ut8 *)cnk, sizeof (GH(RHeapChunk)));
int tc_chunk_size = (cnk->size >> 3) << 3;
tcache_initial_brk = ((brk_start >> 12) << 12) + tc_chunk_size;
initial_brk = tcache_initial_brk;
} else {
initial_brk = (brk_start >> 12) << 12;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,19 @@ EXPECT=<<EOF
p=3
EOF
RUN

NAME=dmh allocated
FILE=../bins/elf/simple_malloc_x86_64
ARGS=-d
CMDS=<<EOF
dcu main
dmh~?allocated
7dso
dmh~?allocated
EOF
EXPECT=<<EOF
1
2
p=3
EOF
RUN