Bug 250185

Summary: lang/php81: Fail posix_getpwnam, posix_getpwuid, ...
Product: Ports & Packages Reporter: Andrey Linkevich <dl>
Component: Individual Port(s)Assignee: Muhammad Moinur Rahman <bofh>
Status: Closed Feedback Timeout    
Severity: Affects Many People CC: bofh, otis, tatsuki_makino
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
php_FreeBSD_sysconf none

Description Andrey Linkevich 2020-10-07 17:13:34 UTC
Created attachment 218596 [details]
php_FreeBSD_sysconf

I am opened the problem https://bugs.php.net/bug.php?id=80198 .
Duplicate for you:


All FreeBSD do not implement the function sysconf with arguments _SC_GETGR_R_SIZE_MAX , _SC_GETPW_R_SIZE_MAX.

php use this sysconf() in:
- main/main.c php_get_current_user()
- main/fopen_wrappers.c php_fopen_primary_script()
- ext/posix/posix.c posix_getpwnam(), posix_getpwuid(), posix_getgrnam(), posix_getgrgid()
- ext/standard/filestat.c php_get_uid_by_name(), php_get_gid_by_name()

The problem is the unsuccessful result for these functions.

Eliminated is trivial. patch applied.
Comment 1 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2022-02-23 18:57:57 UTC
Is this reproducible in latest php74 ?
Comment 2 Andrey Linkevich 2022-02-24 06:10:53 UTC
Yes
Comment 3 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2022-03-04 02:09:49 UTC
Is this the fact in php80 and 81 too?
Comment 4 Andrey Linkevich 2022-03-04 06:15:50 UTC
Yes. php-8.0.16 and php-8.1.3
Comment 5 Tatsuki Makino 2023-05-28 02:09:07 UTC
-1 is returned because it is hard-coded :)
Comments to that effect seem to be around here.

https://cgit.freebsd.org/src/tree/lib/libc/gen/sysconf.c#n366
Comment 6 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2023-12-21 22:56:20 UTC
This is no longer reproducible with php80 and later.
Comment 7 Tatsuki Makino 2023-12-23 07:35:56 UTC
(In reply to Muhammad Moinur Rahman from comment #6)

I thought it was true because it was not reproduced in php81-posix-8.1.26_1, but I updated to php81-posix-8.1.27 today and it reproduced.
I don't get it :)

Option ZTS in lang/php81 must be toggled on.
The code used to reproduce it looks like this.

> php -r 'var_dump(PHP_VERSION, posix_getgrgid(80), posix_getgrnam("www"));'
string(6) "8.1.27"
bool(false)
bool(false)
Comment 8 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2023-12-23 14:12:56 UTC
Ah no. I think I did not check with ZTS hence I deleted the patch. :(

I am also following up a PR:
https://github.com/php/php-src/pull/12995

Let me check it.
Comment 9 Tatsuki Makino 2023-12-23 21:43:12 UTC
(In reply to Muhammad Moinur Rahman from comment #8)

That's where the patch existed :)
I think that upstream should change the flow instead of using the patch here.

-1 and negative numbers are given special treatment.
The size of the result is scalable in environments where positive numbers are provided.
Realloc and retry with the sysconf value as the maximum value.
or something...
Comment 10 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2024-01-18 18:30:40 UTC
I have fixed the patches in the latest updates. Let me know if it works.