macOS getgrent returns no groups while getgrgid works
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 47/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- backend, operating-systems
Research direction
Start by reading ExtendedNativeUtils.getgrent, FFMPosixLinux.getgrent, and FFMPosixMacOS to trace the native call and how a null result becomes an empty list. Then compare the macOS FFM binding and enumeration setup with the host libc behavior; the issue says the failure occurs on both execution backends. Done means successive getgrent calls return group records after setgrent, with regression coverage for list context and File::Finder's nogroup predicates.
Written by the indexing model from the issue text.
Description
Summary
On macOS, PerlOnJava's getgrent returns no group entries, even though getgrgid can look up a group by GID. This breaks Perl code that enumerates the group database. It causes the released CPAN distribution File-Finder 1.01 to misclassify every path for its nogroup and not nogroup predicates.
Reproduction
The following probe was run with both the JVM backend and --interpreter:
my $gid = (stat ".")[5];
my @by_gid = getgrgid($gid);
print "gid=$gid getgrgid=", scalar(@by_gid), " ", join("|", @by_gid), "\n";
setgrent();
my @entry = getgrent();
print "getgrent=", scalar(@entry), " ", join("|", @entry), "\n";
PerlOnJava reports a valid getgrgid record, then getgrent=0. Repeated getgrent calls also return no entries. System Perl on the same macOS host returns group entries from getgrent (and a valid record from getgrgid).
CPAN evidence
In CPAN random tester run 20261109-091152-39587, File-Finder-1.01 failed 2 of 87 tests, both in t/05-steps.t:
nogroup: PerlOnJava included.although the system-Perl expected result was empty.not nogroup: PerlOnJava returned an empty result although system Perl included..
System Perl passed all 87 tests. The other File-Finder tests passed or were skipped for optional dependencies. This is a pure-Perl distribution; no XS/native distribution prioritization applies.
The affected code in File-Finder builds a GID-to-group map by iterating getgrent. Because PerlOnJava returns no entries, _gid_to_group cannot resolve the directory's GID; nogroup then treats it as unknown. The same failure was observed with both PerlOnJava backends.
Suspected implementation path
ExtendedNativeUtils.getgrent calls FFMPosix.get().getgrent() and converts a null native result into an empty Perl list. The FFM implementation in FFMPosixLinux.getgrent invokes the native getgrent handle and returns null when the pointer is null. On macOS, FFMPosixMacOS inherits this implementation. In contrast, the native getgrgid path succeeds for the current GID.
This localizes the failure to native group enumeration, shared by the two execution backends. The precise reason the native getgrent call returns null still needs investigation; likely follow-up is to validate the macOS FFM binding and enumeration setup against the platform libc behavior.
Expected behavior
After setgrent, successive getgrent calls should enumerate the same available group records as system Perl on the host. The regression should cover list-context results and the File::Finder nogroup/not nogroup behavior on both execution backends.
- Dominant language
- Perl
- Stars
- 67
- Forks
- 8
- Avg merge
- 5h 12m
- Merged PRs (30d)
- 131
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from fglock/PerlOnJava
-
area:cpan-port bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
fglock/PerlOnJava#2153 ·
Maintainers usually reply within 1 day
-
area:cpan-port area:parser bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
fglock/PerlOnJava#2137 ·
Maintainers usually reply within 1 day
-
area:backend area:cpan-port area:runtime bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
fglock/PerlOnJava#2071 ·
Maintainers usually reply within 1 day
-
area:runtime documentation enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
fglock/PerlOnJava#1579 ·
Maintainers usually reply within 1 day
-
area:cpan-port bug
Difficulty 3/5 1-2 days Newbie friendliness 62/100
fglock/PerlOnJava#2157 ·
Maintainers usually reply within 1 day
All issues in fglock/PerlOnJava
Similar issues
-
Dev-output directory preparation accepts file-valued lib/include paths and fails on dangling linksOpenteam-cli
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
Difficulty 1/5 Under an hour Newbie friendliness 93/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
inverse-inc/packetfence#9728 ·
Maintainers usually reply within 1 day
-
fix(char-create): show the real reason a character is refusedPossibly taken @baphomello claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day