fix: skip FileDescriptorsLen fast path on non-Linux/FreeBSD platforms#853
Open
kazeburo wants to merge 1 commit into
Open
fix: skip FileDescriptorsLen fast path on non-Linux/FreeBSD platforms#853kazeburo wants to merge 1 commit into
kazeburo wants to merge 1 commit into
Conversation
Signed-off-by: Masahiro Nagano <m-nagano@sakura.ad.jp>
kazeburo
force-pushed
the
fix-isrealproc-function
branch
from
July 24, 2026 09:21
83b9adb to
621343b
Compare
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
Fix
Proc.FileDescriptorsLen()returning incorrect values on macOS and other non-Linux/FreeBSD platforms whereisRealProc()was incorrectly returningtrue.Problem
On macOS,
Proc.FileDescriptorsLen()returns incorrect values because the fast path (introduced in Linux v6.2) relies onstat.Size()semantics that are only valid on Linux. For example, on macOS with test fixtures, this caused:The fast path uses
stat.Size()to get the directory entry count, which on macOS returns directory metadata (e.g., inode count or block size) instead of the actual number of file descriptors.This happened because
isRealProc()infs_statfs_notype.gowas returningtrueon non-Linux/FreeBSD platforms, causing the fast path to be incorrectly applied.Changes
isRealProc()infs_statfs_notype.goto returnfalse, nilinstead oftrue, nilThis ensures that on platforms without
Statfs_t.Type(macOS, etc.), the fast path is skipped and the correct result fromlen(fds)is returned.The fast path relying on
stat.Size()semantics for directory block counts is only valid on Linux and FreeBSD, so returningfalseon other platforms is semantically correct.Impact
fs_statfs_type.gocontinues to checkPROC_SUPER_MAGICFileDescriptorsLen()now returns the correct file descriptor count instead of directory metadata values