pwndbg icon indicating copy to clipboard operation
pwndbg copied to clipboard

Add limit flag for heap commands which overrides heap-dereference-limit

Open k4lizen opened this issue 1 year ago • 4 comments

Useful especially when one wants to see more (or less) chunks printed for one run of the command.

As mentioned here: https://github.com/pwndbg/pwndbg/issues/2376#issuecomment-2296825757

k4lizen avatar Aug 28 '24 17:08 k4lizen

EDIT: Eh, obviously "limit flags" are not there, but some limits are passed via heap-dereference-limit. Sorry for my confusion below.

I believe such limit flags are already there:

dc@dc:~/pwndbg$ rg heap_chain_limit
pwndbg/gdblib/heap/__init__.py
51:heap_chain_limit = add_heap_param(

pwndbg/gdblib/heap/ptmalloc.py
776:                limit=pwndbg.gdblib.heap.heap_chain_limit,
1260:                limit=pwndbg.gdblib.heap.heap_chain_limit,
1367:        chain_size = int(pwndbg.gdblib.heap.heap_chain_limit)

pwndbg/commands/heap.py
30:from pwndbg.gdblib.heap import heap_chain_limit
105:                chain_fd[0], limit=heap_chain_limit, offset=offset, safe_linking=safe_lnk

Hmm, the format_bin function does pwndbg.chain.format(..., limit=heap_chain_limit, ...) -- does heap_chain_limit refer to a parameter here, or its copy? I wonder if one does set heap-dereference-limit 100 will this value be properly resolved here?

Update: Yes. I confirmed that this value is resolved properly and an updated value is used.

So the limitation of dereferencing is used properly when displaying various bins and linked lists.

disconnect3d avatar Aug 28 '24 23:08 disconnect3d

Now, yeah, the bins (and maybe some other?) command does not have a --limit flag.

Alternatively to adding such flag, we could extend the help string to inform about heap-dereference-limit parameter.

disconnect3d avatar Aug 29 '24 00:08 disconnect3d

@k4lizen is this still valid and needed? maybe we implemented it somehow? shall we close it?

disconnect3d avatar Mar 27 '25 13:03 disconnect3d

Hm, where did the original issue go? It had some relevant info :(

It is valid and unimplemented though probably not too important a feature

k4lizen avatar Mar 27 '25 14:03 k4lizen