vmmap output is inaccurate when use remote debug and load a local file.
remote:
# run gdbserver
gdbserver --multi 0.0.0.0:1234
# open a new terminal and run a program such as /bin/sh
/binary/sh
local:
# run gdb in terminal
gdb ./sh
# run in gdb
target extended-remote 172.20.0.3:1234
attach {/binary/sh 's pid}
And I found that vmmap cannot recognize heap correctly.

pwndbg> version
Gdb: 9.1
Python: 3.7.6 (default, Jan 19 2020, 22:34:52) [GCC 9.2.1 20200117]
Pwndbg: 1.1.0 build: 8cbb863
Capstone: 4.0.1024
Unicorn: 1.0.2
I confirmed this bug in https://github.com/pwndbg/pwndbg/pull/705#issuecomment-587002280. As described there, this is a cache-related bug.
Since this is a caching-related issue, it might be worth building some caching-related instrumentation that shows when the cached result differs from the actual result when they are expected to be the same (because of the caching).
This might make it easier to track down issues like this, but I'm not sure how much work it is.
TL;DR It would be useful to have a setting where caching is effectively disabled (i.e. we always call the function-to-be-cached) but we keep track of the result such that we can tell when our cache is not correct.
@zachriggle Great idea. I used that locally, found the bug and fixed it in https://github.com/pwndbg/pwndbg/commit/ca649da0e34cb150b5f4614c25efb284a28e5d39 :).
@plusls please check the latest dev if it is fixed for you.
Patch used for instrumenting cache below, not sure if we want it in this form. It requires firing pi pwndbg.memoize.memoize.caching=False and pi pwndbg.memoize.memoize.instrumentation=True before doing anything else.
diff --git a/pwndbg/memoize.py b/pwndbg/memoize.py
index 59f857b..0e1de96 100644
--- a/pwndbg/memoize.py
+++ b/pwndbg/memoize.py
@@ -24,6 +24,7 @@ class memoize(object):
Base memoization class. Do not use directly. Instead use one of classes defined below.
"""
caching = True
+ instrumentation = False # Works only if caching is False
def __init__(self, func):
self.func = func
@@ -43,6 +44,15 @@ class memoize(object):
how = "Cached"
value = self.cache[args]
+ elif self.instrumentation and args in self.cache:
+ cv = self.cache[args]
+ rv = self.func(*args, **kwargs)
+ if cv != rv:
+ print("Mismatch in cache for %s(%s, %s)" % (self.func.__name__, args, kwargs))
+ print("See rv (real value) and cv (cached value) variables")
+ import pdb
+ pdb.set_trace()
+
else:
how = "Executed"
value = self.func(*args, **kwargs)
it works.
Most helpful comment
Since this is a caching-related issue, it might be worth building some caching-related instrumentation that shows when the cached result differs from the actual result when they are expected to be the same (because of the caching).
This might make it easier to track down issues like this, but I'm not sure how much work it is.
TL;DR It would be useful to have a setting where caching is effectively disabled (i.e. we always call the function-to-be-cached) but we keep track of the result such that we can tell when our cache is not correct.