Fix region prioritization in dump_process_memory. - #235
Open
grrrrrrrrr wants to merge 1 commit into
Open
Conversation
`dump_process_memory::sort_by_priority` contained two algorithmic flaws: 1. When iterating over sorted `offsets`, regions preceding the current offset were popped and placed at the back with `deque.push_back`. Because these regions were consumed from the iterator, subsequent offset iterations could no longer match them, dropping regions from consideration and scrambling the non-priority region order. 2. Matched priority regions were prepended using `deque.push_front`, which reversed the requested relative priority order when multiple priority offsets matched distinct regions. This change refactors the function to partition the memory regions into priority and non-priority collections by checking whether any address in `offsets` falls within `[start_address, end_address)` using binary search, preserving the original monotonic address order for both groups.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dump_process_memory::sort_by_prioritycontained two algorithmic flaws:offsets, regions preceding the currentoffset were popped and placed at the back with
deque.push_back.Because these regions were consumed from the iterator, subsequent
offset iterations could no longer match them, dropping regions from
consideration and scrambling the non-priority region order.
deque.push_front,which reversed the requested relative priority order when multiple
priority offsets matched distinct regions.
This change refactors the function to partition the memory regions into
priority and non-priority collections by checking whether any address in
offsetsfalls within[start_address, end_address)using binary search,preserving the original monotonic address order for both groups.