php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63369 (un)serialize() leaves dangling pointers, causes crashes
Submitted: 2012-10-26 12:23 UTC Modified: 2012-10-26 12:44 UTC
From: [email protected] Assigned: tony2001 (profile)
Status: Closed Package: Reproducible crash
PHP Version: 5.4Git-2012-10-26 (Git) OS: *
Private report: No CVE-ID: None
 [2012-10-26 12:23 UTC] [email protected]
Description:
------------
When a fatal error happens in a __sleep/__wakeup function, BG(serialize) and 
BG(unserialize) contents is left intact and the next request will get those pointers 
again, even though at that moment they are already freed by Zend memory manager 
during request shutdown.
If you're lucky, there is a chance you'll reuse them, which causes immediate crash.
The attached scripts demonstrates the problem with serialize() and I'm kinda lazy to 
do the same for unserialize(), especially taking into account that the patch is 
extremely simple.

Test script:
---------------
class bar1 {
	function __sleep() {
		foo();
	}
}

class foo1 {
	function __sleep() {
		var_dump(serialize(array("test", "1", 234)));
		var_dump(serialize(new bar1));
	}
}

$o = new foo1;

var_dump(unserialize('O:8:"stdclass":0:{}')); //to clear BG(serialize_lock)
var_dump(serialize($o));

Expected result:
----------------
.

Actual result:
--------------
.

Patches

the-patch (last revision 2012-10-26 12:24 UTC by [email protected])

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-10-26 12:24 UTC] [email protected]
The following patch has been added/updated:

Patch Name: the-patch
Revision:   1351254242
URL:        https://bugs.php.net/patch-display.php?bug=63369&patch=the-patch&revision=1351254242
 [2012-10-26 12:43 UTC] [email protected]
-Status: Open +Status: Closed
 [2012-10-26 12:44 UTC] [email protected]
Merged patches f2bffdc and 01dee2c.
 [2012-10-26 12:44 UTC] [email protected]
-Assigned To: +Assigned To: tony2001
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 29 08:00:02 2025 UTC