|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-12-04 06:39 UTC] h dot kocznar at compunect dot com
[2019-12-04 07:20 UTC] stas@php.net
-Type: Security
+Type: Bug
[2019-12-04 07:50 UTC] nikic@php.net
[2019-12-04 07:50 UTC] nikic@php.net
-Status: Open
+Status: Feedback
[2019-12-15 04:22 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Mar 04 14:00:01 2026 UTC |
Description: ------------ I fear I can't supply a full test script but I've a reproduceable case here with PHP 7.2.7. I've a variable type corruption and randomized segfaults of php itself. segfault at 7f58b9c366f7 ip 00007f58b9c366f7 sp 00007f58a03fea60 error 14 in ctype.so[7f58ba07e000+3000] segfault at 7f58b9c366f7 ip 00007f58b9c366f7 sp 00007f58a15fea60 error 14 in xdebug.so[7f58bb546000+40000] segfault at 7f58b9c366f7 ip 00007f58b9c366f7 sp 00007f58a0bfea60 error 14 in xml.so[7f58baaaa000+b000] segfault at 7f58b9c366f7 ip 00007f58b9c366f7 sp 00007f58a0bfea60 error 14 in pdo.so[7f58bacb7000+19000] I've a function circular() which keeps a static variable that's used to store up to n (100) entries in a script that's processing coordinates. The function uses array_shift() to remove the oldest element from the static array when the size reaches 100. The variable normally contains elements like this: '2baa468ffd1672f235a35b55dbbbde80' => array(6) { 'country_name' => string(13) "United States" 'state_name' => string(4) "Ohio" 'city_name' => string(10) "Youngstown" 'zip_code' => NULL 'distance_km' => double(1.7982744310941) 'returncode' => bool(true) } However after running for a 102 cycles (2nd array_shift()) I'm getting a memory consumption error (256MB used, though only 100 entries are kept). In addition the array content suddenly changes from an array into a string type. string(300668) "Anited States "... It works fine without array_shift() Test script: --------------- public static function circular(string $identifier, string $key=NULL,$value=NULL, int $size=100) { static $storage=[]; if ($identifier == 'GET') var_dump($storage); if (empty($key) && empty($value)) return $storage[$identifier]??[]; if (!empty($key) && empty($value)) { $key=(string)md5($key); return $storage[$identifier][$key]??NULL; } // storage if (empty($key)) { $storage[$identifier][]=$value; } { $key=(string)md5($key); $storage[$identifier][$key]=$value; } if (count($storage[$identifier]) > $size) $storage[$identifier] = array_shift($storage[$identifier]); // this here causes the segfaults/corruption return true; }