mallocng: Add ng-metaarea and ng-ctx commands#3164
Conversation
k4lizen
commented
Jul 20, 2025
There was a problem hiding this comment.
Pull Request Overview
This PR adds two new commands to the mallocng debugging functionality: mallocng-meta-area (alias ng-metaarea) and mallocng-malloc-context (alias ng-ctx) for inspecting mallocng allocator structures. Additionally, it improves error handling in existing commands by properly checking the return value of init_if_needed().
Key changes include:
- Addition of two new commands with corresponding dump functions for detailed structure inspection
- Enhanced error handling for allocator initialization failures
- Code quality improvements with type annotations and minor refactoring
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pwndbg/commands/mallocng.py | Adds new commands and improves error handling for allocator initialization |
| pwndbg/aglib/heap/mallocng.py | Adds type annotations, refactors code, and enhances init_if_needed() return handling |
| docs/commands/musl/mallocng-meta-area.md | Documentation for the new mallocng-meta-area command |
| docs/commands/musl/mallocng-malloc-context.md | Documentation for the new mallocng-malloc-context command |
| docs/commands/index.md | Updates command index to include the new commands |
| if self.hope: | ||
| self.finished_init = True |
There was a problem hiding this comment.
The indentation is incorrect. This line and the following line should be dedented to align with the previous statements in the function.
| if self.hope: | |
| self.finished_init = True | |
| if self.hope: | |
| self.finished_init = True |
| self.finished_init = True | ||
| # We will try to reinitialize again if we failed now. | ||
| if self.hope: | ||
| self.finished_init = True |
There was a problem hiding this comment.
The indentation is incorrect. This line should be dedented to align with the previous statements in the function.
| self.finished_init = True | |
| self.finished_init = True |
|
|
||
| for addr, mapname in possible: | ||
| if mapname.contains("libc"): | ||
| if "libc" in mapname: |
There was a problem hiding this comment.
Is this fine? "libcrypto" will match here
There was a problem hiding this comment.
hmm I mean, this will only iterate over mappings that contain the AT_RANDOM+8 value, but I guess libcrypto might use this..
I'll check
There was a problem hiding this comment.
it doesn't, should be good :>