php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61453 SplObjectStorage does not identify objects correctly
Submitted: 2012-03-20 12:41 UTC Modified: 2012-03-21 12:45 UTC
From: jhgundersen at gmail dot com Assigned: cataphract (profile)
Status: Closed Package: SPL related
PHP Version: 5.4.0 OS: Linux
Private report: No CVE-ID: None
 [2012-03-20 12:41 UTC] jhgundersen at gmail dot com
Description:
------------
When I have a large collection of objects stored in a SplObjectStorage it starts 
to behave strange. It says that an object already exists in the storage and 
returns the stored data for another object. 

Test script:
---------------
$limit = 1000;
$objects = new SplObjectStorage;
for($i = 0; $i < $limit; $i++){
	$object = new StdClass;

	if(isset($objects[$object])){
		die("this should never happen, but did after $i iteration");
	}

	$objects[$object] = 1;
}

echo "\nfinished\n";

Expected result:
----------------
The script should never enter the if condition and die, because the object has 
not been added to the object storage yet

Actual result:
--------------
The scripts dies because of it finding an object in the storage that should not 
have been there. This happens at random iteration, i'm guessing based on memory 
usage or something.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-21 12:30 UTC] cataphract@php.net
-Assigned To: +Assigned To: cataphract
 [2012-03-21 12:45 UTC] cataphract@php.net
-Status: Assigned +Status: Closed
 [2012-03-21 12:45 UTC] cataphract@php.net
Fixed in git. Thank you.
 [2014-10-07 23:28 UTC] stas@php.net
Automatic comment on behalf of cataphract
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=0f001703a8987960de041b216a023869ab439857
Log: Fixed bug #61453.
 [2014-10-07 23:39 UTC] stas@php.net
Automatic comment on behalf of cataphract
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=0f001703a8987960de041b216a023869ab439857
Log: Fixed bug #61453.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 22:01:28 2024 UTC