php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60919 __wakeup is not called
Submitted: 2012-01-28 20:58 UTC Modified: 2012-02-23 18:34 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:2 (100.0%)
From: thekid@php.net Assigned: stas (profile)
Status: Duplicate Package: Scripting Engine problem
PHP Version: 5.4.0RC6+ OS: (Any)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: thekid@php.net
New email:
PHP Version: OS:

 

 [2012-01-28 20:58 UTC] thekid@php.net
Description:
------------
In 5.4.0RC6, a __wakeup() method is no longer called during unserialization.

Test script:
---------------
$ php -r 'class A { function __sleep() { echo "SLEEP\n"; return array(); } function __wakeup() { echo "WAKEUP"; }} $a= unserialize(serialize(new A()));'


Expected result:
----------------
SLEEP
WAKEUP
object(A)#1 (0) {
}


Actual result:
--------------
SLEEP
object(A)#1 (0) {
}


Patches

init-serialize-levels.diff (last revision 2012-02-05 14:03 UTC) by thekid@php.net)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-28 21:15 UTC] rasmus@php.net
-Status: Open +Status: Critical
 [2012-01-28 21:23 UTC] rasmus@php.net
-Status: Critical +Status: Feedback
 [2012-01-28 21:23 UTC] rasmus@php.net
I can't actually reproduce this in the current 5.4 code:

% php --version
PHP 5.4.0RC7-dev (cli) (built: Jan 28 2012 13:21:30) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

% php -r 'class A { function __sleep() { echo "SLEEP\n"; return array(); } 
function __wakeup() { echo "WAKEUP"; }} $a= unserialize(serialize(new A()));'
SLEEP
WAKEUP
 [2012-02-04 17:47 UTC] thekid@php.net
-PHP Version: 5.4.0RC6 +PHP Version: 5.4.0RC6+
 [2012-02-04 17:47 UTC] thekid@php.net
But still occurs in php-5.4.0RC7-nts-Win32-VC9-x86 (2012-Feb-02 23:15:00)
 [2012-02-05 14:00 UTC] thekid@php.net
I can also not reproduce the issue if I compile PHP myself, neither on Linux nor on Windows.

From looking at the diffs between 5.4.0RC5 and current SVN, BG(serialize_lock) in conjunction with BG(unserialize).level and BG(serialize).level) sticks out. The thing I think is suspicous here is that BG(unserialize).level gets assigned to 1 inside a block guarded by if (... || !BG(unserialize).level) {, but is never assigned to 0. 

Are we running into this problem because BG(unserialize).level doesn't properly get initialized? I'm not an expert here but is it safe to rely on the compiler doing thos?

Same goes for BG(serialize).level, by the way.
 [2012-02-05 14:03 UTC] thekid@php.net
The following patch has been added/updated:

Patch Name: init-serialize-levels.diff
Revision:   1328450632
URL:        https://bugs.php.net/patch-display.php?bug=60919&patch=init-serialize-levels.diff&revision=1328450632
 [2012-02-05 16:28 UTC] rasmus@php.net
You should ask Stas for permission to commit this patch to 5.4 before the 
release. Initializing uninitialized variables tends to be a good idea.
 [2012-02-05 18:02 UTC] thekid@php.net
-Assigned To: +Assigned To: stas
 [2012-02-05 18:02 UTC] thekid@php.net
Stas, can you have a look at the patch? Thanks!
 [2012-02-20 10:48 UTC] pajoye@php.net
Duplicate of #60879
 [2012-02-20 10:48 UTC] pajoye@php.net
-Status: Feedback +Status: Duplicate -Assigned To: stas +Assigned To: pajoye
 [2012-02-20 10:52 UTC] pajoye@php.net
-Status: Duplicate +Status: Feedback -Assigned To: pajoye +Assigned To: stas
 [2012-02-20 10:52 UTC] pajoye@php.net
Actually maybe still valid on other platform than windows, but so far our tests on 
linux (x86&x64) did not show any issue with this issue.

Timm, which platforms exactly do you use to test? The other bug I referred to 
(#60879) is a windows only bug and only due to the release build process, not to a 
bug in our code base.
 [2012-02-23 18:34 UTC] thekid@php.net
-Status: Feedback +Status: Duplicate
 [2012-02-23 18:34 UTC] thekid@php.net
Yes, also looks like a dup of #60879 to me; and the patched RC8 there works for me. I'll close this.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC