macOS getgrent returns no groups while getgrgid works

オープン
#2,009 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
47/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
java, perl

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

area:platform area:runtime bug

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.

主要言語
Perl
スター
67
フォーク
8
平均マージ
5時間 12分
マージ済み PR(30日)
131

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

fglock/PerlOnJava のほかの issue

fglock/PerlOnJava の issue をすべて見る

似ている issue

Perl の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。