Bug #79990 [NEW]: glob() returns duplicate values

From: Date: Tue, 18 Aug 2020 14:58:58 +0000
Subject: Bug #79990 [NEW]: glob() returns duplicate values
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228643@lists.php.net to get a copy of this message
From:             bonzura at yahoo dot co dot jp
Operating system: Windows10
PHP version:      7.4.9
Package:          Filesystem function related
Bug Type:         Bug
Bug description:glob() returns duplicate values

Description:
------------
glob() returns duplicate values ​​when the number of files is 65534
or more.

It occurs only in Windows PHP ver 7.4.9 or earlier, not in 8.0 or
Linux.

When number of files increase, duplicate values also increase.

When I tried Test script $max=1000000, result is below.
--------
1000015
Duplicated test/0000065534.txt->2
Duplicated test/0000131069.txt->2
Duplicated test/0000196604.txt->2
Duplicated test/0000262139.txt->2
Duplicated test/0000327674.txt->2
Duplicated test/0000393209.txt->2
Duplicated test/0000458744.txt->2
Duplicated test/0000524279.txt->2
Duplicated test/0000589814.txt->2
Duplicated test/0000655349.txt->2
Duplicated test/0000720884.txt->2
Duplicated test/0000786419.txt->2
Duplicated test/0000851954.txt->2
Duplicated test/0000917489.txt->2
Duplicated test/0000983024.txt->2


Test script:
---------------
<?php
$max=65534;
$dir='test/';
for ($i=1;$i<=$max;$i++){
    file_put_contents($dir.sprintf("%010d",$i).".txt",$i);
}

$files=glob($dir."*");
echo count($files)."\n";

$check=array_count_values($files);
foreach ($check as $key=>$value){
	if ($value!=1){
		echo "Duplicated ".$key."->".$value."\n";
	}
}
?>

Expected result:
----------------
65534

Actual result:
--------------
65535
Duplicated test/0000065534.txt->2

-- 
Edit bug report at https://bugs.php.net/bug.php?id=79990&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=79990&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=79990&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=79990&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=79990&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=79990&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=79990&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=79990&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=79990&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=79990&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=79990&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79990&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=79990&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=79990&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=79990&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=79990&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=79990&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=79990&r=mysqlcfg


Thread (2 messages)

« previous php.bugs (#228643) next »