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

small change to largebins() and contains_chunk() #1314

Merged
merged 2 commits into from
Oct 22, 2022
Merged

Conversation

pogen300
Copy link
Contributor

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

@@ -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
Copy link
Member

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?

Copy link
Member

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.

@@ -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
Copy link
Member

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.

Copy link
Member

@gsingh93 gsingh93 left a 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.

@gsingh93 gsingh93 merged commit aaf9ad2 into pwndbg:dev Oct 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants