php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28935 Operation is amusing when a constant is set up by __set to the overloaded class
Submitted: 2004-06-28 03:26 UTC Modified: 2005-05-22 01:00 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: khagiya1 at yahoo dot co dot jp Assigned:
Status: No Feedback Package: Class/Object related
PHP Version: 4CVS OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: khagiya1 at yahoo dot co dot jp
New email:
PHP Version: OS:

 

 [2004-06-28 03:26 UTC] khagiya1 at yahoo dot co dot jp
Description:
------------
When __set is called to the class by which the overload was carried out, 
operation by FOO and constant ('FOO') is different.

Reproduce code:
---------------
<?php

define( 'FOO', 'BAR' );

class line
{
    var $_data = array();
    
    function set( $key, $value )
    {
        $this->_data[$key] = $value;
    }
    function get( $key )
    {
        return $this->_data[$key];
    }
}

class Info
{
    var $_data = null;
    
    function Info( & $line )
    {
        $this->_data = array( & $line );
    }
    function __set( $key, $value )
    {
        $data =& $this->_data;
        $data[0]->set( $key, $value );
        return TRUE;
    }
    function __get( $key, &$value )
    {
        $data = $this->_data;
        $ret =& $data[0]->get( $key );
        $value = $ret;
        return TRUE;
    }
}

overload( 'Info' );

$test = new Info( new line );

// [case 1 = fail]
$test->x = FOO;
echo $test->x;

// [case 2 = success]
//$test->x = constant('FOO');
//echo $test->x;

// [case 3 = crash!!!!!]
// When it calls simultaneously
//$test->x = FOO;
//$test->y = constant('FOO');

?>

Expected result:
----------------
//[case 1]
BAR

//[case 2]
BAR

//[case 3]
BAR
BAR

Actual result:
--------------
//[case 1]
xR     (why???)

//[case 2]
BAR    (ok!!!)

//[case 3]
segfault!!!!!

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-11 21:28 UTC] sniper@php.net
Output with case 1 (linux):
---------------------------
PHP Warning:  String is not zero-terminated (x) (source:
/usr/src/web/php/php4/Zend/zend_execute.c:281) in /home/jani/t.php on
line 36

Warning: String is not zero-terminated (x) (source:
/usr/src/web/php/php4/Zend/zend_execute.c:281) in /home/jani/t.php on
line 36
x
 PHP Warning:  String is not zero-terminated (ZZ
                                                ?***) (source:
/usr/src/web/php/php4/Zend/zend_execute_API.c:291) in Unknown on line 0

Warning: String is not zero-terminated (ZZ
                                          ?***) (source:
/usr/src/web/php/php4/Zend/zend_execute_API.c:291) in Unknown on line 0
[Sun Jul 11 21:38:02 2004]  Script:  't.php'
---------------------------------------
/usr/src/web/php/php4/Zend/zend_execute_API.c(291) : Block 0x08618F28
status:
/usr/src/web/php/php4/Zend/zend_variables.c(44) : Actual location
(location was relayed)
Beginning:      Cached (allocated on
/usr/src/web/php/php4/Zend/zend_execute.c:911, 2 bytes)
      End:      OK
---------------------------------------
[Sun Jul 11 21:38:02 2004]  Script:  't.php'
---------------------------------------
/usr/src/web/php/php4/Zend/zend_execute.h(44) : Block 0xBFFFBCF4
status:
Beginning:      Overrun (magic=0x00420297, expected=0x7312F8DC)
Fatal System Error: Raise at top of Exception Stack
Aborted

Backtrace:
----------
http://www.php.net/~jani/bug28935_gdb.bt
 [2005-05-14 15:54 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

Can't reproduce it with latest PHP4 CVS.
 [2005-05-22 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Oct 12 15:01:27 2024 UTC