{{ message }}
Repository navigation
Use the requested pid in the Linux memory grabber - #7011
Merged
Merged
Conversation
The Linux MEMORY_GRABBER lambda takes a pid argument but read
/proc/#{$$}/status (the current process) instead of /proc/#{pid}/status,
ignoring its argument. The darwin/bsd branch correctly uses pid. The bug
has been latent since sidekiq#4717 because the only caller passes Process.pid,
so $$ and pid are always equal in practice. Use pid so the grabber
honors its argument and matches the other platforms.
Adds a Linux-guarded regression test: calling the grabber with a
non-existent pid must raise Errno::ENOENT (it now reads that pid's
/proc entry), which fails against the old $$ behavior.
Contributor
Author
mperham
pushed a commit
that referenced
this pull request
May 29, 2026
Follow-up coverage for the memory grabber fixed in #7011. The existing tests only call MEMORY_GRABBER with $$ (plus a Linux-only check), and the memory_usage wrapper was untested. Add cross-platform coverage that the grabber reads a different process by pid (Process.ppid) and that memory_usage returns a positive integer for a given pid.
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.

Summary
The Linux branch of
MEMORY_GRABBER(lib/sidekiq/launcher.rb) takes apidargument but ignores it, reading the current process instead:The
darwin|bsdbranch correctly usespid(ps -o pid,rss -p #{pid}). The bug has been latent since #4717 because the only caller ismemory_usage(::Process.pid), so$$andpidare always equal in practice — but the lambda is parameterized bypidand should honor it (and stay consistent across platforms).Fix: read
/proc/#{pid}/status.Testing
Adds a Linux-guarded regression test: calling the grabber with a non-existent pid must raise
Errno::ENOENT(it now reads that pid's/procentry). This fails against the old$$behavior (which silently returns the current process's RSS) and passes after the fix. It skips on non-Linux platforms where this lambda isn't used.bundle exec rakeis green (standard + lint:herb + full suite; the new test skips locally on macOS and runs on Linux CI).