php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12793 __sleep causing problems
Submitted: 2001-08-16 10:28 UTC Modified: 2002-03-19 06:25 UTC
From: clownfighter at hotmail dot com Assigned:
Status: Closed Package: Session related
PHP Version: 4.0CVS-2002-03-0 OS: Linux
Private report: No CVE-ID: None
 [2001-08-16 10:28 UTC] clownfighter at hotmail dot com
When I create a db connection object, call it "conn", with a __sleep function to close the connection when the object is serialized for a session, any object which has an instance of "conn" fails to load properly. For instance, if I have an object "permissions" that has a "conn" object, when I unserialize "permissions" from a session the class appears to never be defined. I don't get any error messages until I try to use "permissions," in which case it says "Call to a function of a non-object" whenever I try to use a function of "permissions." Never do I get an error from "conn" or "permissions."

Comment out the __sleep function in "conn" and things work fine.


My configure line:
 './configure' '--with-postgres' '--with-gd' '--with-pspell' '--with-apxs'

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-05 10:19 UTC] sander@php.net
Can you provide a _simple_ sample-script?
 [2001-12-26 18:51 UTC] lobbin@php.net
No feedback. Closing.
 [2002-03-06 07:14 UTC] flying at dom dot natm dot ru
Confirm this bug on PHP 4.0.6 and 4.1.1 on Windows 2000 Server and Apache 1.3.23

Here is requested testcase:

<?php
class myClass
{
    function myClass()
    {
    }

    function __sleep()
    {
        echo 'sleep!<br>';
    }

    function __wakeup()
    {
        echo 'wakeup!<br>';
    }
};

$obj = new myClass();
$str = serialize($obj);
echo $str."<br>";
$obj2 = unserialize($str);
print_r($obj2);
?>

 Running this script on PHP 4.0.6 will set $str to empty string (however __sleep() is called properly). Commenting out __sleep() method will return normal serialized value of an object.
 Running this script on PHP 4.1.1 cause PHP to crash.

 Please reopen this bug or i'll submit new one :)
 [2002-03-06 08:11 UTC] edink@php.net
I can reproduce the crash with the following backtrace:

Starting program: /home/ek/projects/php/php4/sapi/cli/php -f ~/t
sleep!<br>
Program received signal SIGSEGV, Segmentation fault.
0x80dc1c8 in php_var_serialize (buf=0x7fffe3e0, struc=0x816c6ec, var_hash=0x7fffe3ec)
    at var.c:561
561             smart_str_0(buf);
(gdb) bt
#0  0x80dc1c8 in php_var_serialize (buf=0x7fffe3e0, struc=0x816c6ec,
    var_hash=0x7fffe3ec) at var.c:561
#1  0x80dc24f in zif_serialize (ht=1, return_value=0x81773ec, this_ptr=0x0,
    return_value_used=1) at var.c:583
#2  0x80f0ed1 in execute (op_array=0x81715d4) at ./zend_execute.c:1598
#3  0x807011c in zend_execute_scripts (type=8, retval=0x0, file_count=3) at zend.c:810
#4  0x807d51f in php_execute_script (primary_file=0x7ffff8dc) at main.c:1377
#5  0x805ad89 in main (argc=3, argv=0x7ffff944) at php_cli.c:555

 [2002-03-19 05:05 UTC] yohgaki@php.net
Actually a duplicate, but I would like to keep it open since
nice backtrace is in it.
 [2002-03-19 06:25 UTC] thies@php.net
This bug has been fixed in CVS.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 19:01:28 2024 UTC