-
Notifications
You must be signed in to change notification settings - Fork 861
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
small change to largebins() and contains_chunk() #1314
Conversation
@@ -94,10 +94,7 @@ def contains_chunk(self, size, chunk): | |||
|
|||
# TODO: Refactor this, the bin should know how to calculate | |||
# largebin_index without calling into the allocator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to be sure: is this comment still relevant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's still relevant. With an ideal design, there should be no need to call pwndbg.heap.current.largebin_index(size)
, as the algorithm for doing that doesn't depend on having a reference to an actual allocator. Not a big deal right now, but this separation will help in the long run.
pwndbg/heap/ptmalloc.py
Outdated
@@ -94,10 +94,7 @@ def contains_chunk(self, size, chunk): | |||
|
|||
# TODO: Refactor this, the bin should know how to calculate | |||
# largebin_index without calling into the allocator | |||
if size < list(self.bins.items())[0][0]: | |||
return False | |||
size = pwndbg.heap.current.largebin_index(size) - 64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should make a constant for NSMALLBINS and use it here instead of 64, so it's more clear why we're doing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, requested a review from Max.
small change to largebins() and contains_chunk() so that accessing a largebin uses the index (calculated from chunk size) as the key instead of the chunk size