php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9240 unserialize fails non-determenistic on large objects
Submitted: 2001-02-13 10:38 UTC Modified: 2001-07-22 12:48 UTC
From: brian at kusala dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.4pl1 OS: RedHat 6.2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: brian at kusala dot com
New email:
PHP Version: OS:

 

 [2001-02-13 10:38 UTC] brian at kusala dot com
I'm unserializing a large object using the following test script:

for ($i = 0; $i < 20; $i++)
{
	echo "$i\n";
	$ObjectToCreate = array();
	if (!$fp = fopen('test.ser', 'r'))
		return false;
	$ObjectToCreate = unserialize(fread ($fp, filesize ('test.ser')));
	fclose($fp);
}

I get the following output:

0
1
2
3
4
5
6
PHP Warning:  unserialize() failed at offset 2150380 of 3601223 bytes in test.inc on line 8
<font color=ff0000><br>
<b>Warning</b>:  unserialize() failed at offset 2150380 of 3601223 bytes in <b>test.inc</b> on line <b>8</b><br>
</font>7
8
9
10
11
PHP Warning:  unserialize() failed at offset 2822123 of 3601223 bytes in test.inc on line 8
<font color=ff0000><br>
<b>Warning</b>:  unserialize() failed at offset 2822123 of 3601223 bytes in <b>test.inc</b> on line <b>8</b><br>
</font>12
13
14
15
16
17
18
19

Repeatedly running the script produces different output each time with different numbers of failures at different offsets.  So far the lowest offset at which I have had a problem is about 650000.

I can supply the 'test.ser' file on request but for obvious reasons do not wish to include it in this error report!

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-22 10:54 UTC] stas@php.net
Could you please send me smallest possible object that has
this behaviour? If it's large, please compress it.
 [2001-03-20 07:53 UTC] brian at kusala dot com
I have noticed a tendancy for this to occur when the server is particularly short on memory.  My impression is that it is failing with a "can't unserialize at" error instead of a memory error.
 [2001-06-15 10:41 UTC] sniper@php.net
And that example object is where? The small one?

 [2001-07-22 12:48 UTC] andy@php.net
no feedback after 37 days.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 06:01:29 2025 UTC