fix: add missing VmFlags to proc_pid_smaps parser#695
Open
lawrence3699 wants to merge 1 commit intokellyjonbrazil:masterfrom
Open
fix: add missing VmFlags to proc_pid_smaps parser#695lawrence3699 wants to merge 1 commit intokellyjonbrazil:masterfrom
lawrence3699 wants to merge 1 commit intokellyjonbrazil:masterfrom
Conversation
Add wf (wipe on fork), um (userfaultfd missing), and uw (userfaultfd write-protect) flags to vmflags_map. These kernel flags were missing and caused a KeyError crash when encountered in /proc/<pid>/smaps. Also use dict.get() for the VmFlags lookup so that any future unrecognized flags fall back to their raw abbreviation instead of crashing. Fixes kellyjonbrazil#681
There was a problem hiding this comment.
Pull request overview
This PR fixes a crash in the proc_pid_smaps parser when /proc/<pid>/smaps contains previously-unmapped VmFlags values (issue #681), by expanding the known VmFlags map and making the pretty-name lookup resilient to unknown flags.
Changes:
- Add missing
VmFlagsentries (wf,um,uw) to the parser’svmflags_map. - Replace direct
vmflags_map[x]indexing withvmflags_map.get(x, x)to avoidKeyErroron future/unknown flags. - Add a regression test fixture and test case covering the
wfflag.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
jc/parsers/proc_pid_smaps.py |
Adds missing VmFlags and prevents crashes by using a safe lookup fallback. |
tests/test_proc_pid_smaps.py |
Loads the new fixture and adds a regression test for wf. |
tests/fixtures/linux-proc/pid_smaps_wf_flag |
New smaps fixture containing the wf VmFlag. |
tests/fixtures/linux-proc/pid_smaps_wf_flag.json |
Expected parsed JSON output including VmFlags_pretty with “wipe on fork”. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Fixes #681
Problem
The
proc_pid_smapsparser crashes with aKeyErrorwhen/proc/<pid>/smapsoutput contains VmFlags not present invmflags_map. Thewf(wipe on fork) flag, available since Linux 4.14, triggers this crash:Fix
wf(wipe on fork),um(userfaultfd missing pages tracking),uw(userfaultfd write-protect pages tracking).vmflags_map[x]tovmflags_map.get(x, x)so any future unrecognized flags fall back to their raw abbreviation instead of crashing.Validation
KeyErrorbefore the fixtest_proc_pid_smapstests passwfflag