php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21961 get_parent_class segfault
Submitted: 2003-01-30 08:03 UTC Modified: 2003-02-10 08:00 UTC
From: msopacua@php.net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2003-01-30 (dev) OS: FreeBSD 4.7
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: msopacua@php.net
New email:
PHP Version: OS:

 

 [2003-01-30 08:03 UTC] msopacua@php.net
Additionals:
Apache 1.3.27-mod_ssl

Script to reproduce:
<?php

class man
{
        var $name, $bars;
        function man()
        {
                $this->name = 'Mr. X';
                $this->bars = array();
        }

        function getdrunk($where)
        {
                $this->bars[] = new bar($where);
        }

        function getName()
        {
                return $this->name;
        }
}

class bar extends man
{
        var $name;

        function bar($w)
        {
                $this->name = $w;
        }

        function getName()
        {
                return $this->name;
        }

        function whosdrunk()
        {
                $who = get_parent_class($this);
                if($who == NULL)
                {
                        return 'nobody';
                }
                return eval($who.'::getName()');
        }
}

$x = new man;
$x->getdrunk('The old Tavern');
$x->bars[0]->whosdrunk();
?>

Backtrace:
Program received signal SIGSEGV, Segmentation fault.
0x28586642 in zif_get_parent_class (ht=1, return_value=0x8104858, this_ptr=0x0, return_value_used=1)
    at /home/mdev/cvs/php5/Zend/zend_builtin_functions.c:563
563                             name = ce->name;
#0  0x28586642 in zif_get_parent_class (ht=1, return_value=0x8104858, this_ptr=0x0, return_value_used=1)
    at /home/mdev/cvs/php5/Zend/zend_builtin_functions.c:563
#1  0x28594f5b in zend_do_fcall_common_helper (execute_data=0xbfbfe0bc, op_array=0x8106850)
    at /home/mdev/cvs/php5/Zend/zend_execute.c:2620
#2  0x285956a5 in zend_do_fcall_handler (execute_data=0xbfbfe0bc, op_array=0x8106850)
    at /home/mdev/cvs/php5/Zend/zend_execute.c:2748
#3  0x2858f5c7 in execute (op_array=0x8106850) at /home/mdev/cvs/php5/Zend/zend_execute.c:1227
#4  0x28595158 in zend_do_fcall_common_helper (execute_data=0xbfbfe39c, op_array=0x810388c)
    at /home/mdev/cvs/php5/Zend/zend_execute.c:2654
#5  0x28595577 in zend_do_fcall_by_name_handler (execute_data=0xbfbfe39c, op_array=0x810388c)
    at /home/mdev/cvs/php5/Zend/zend_execute.c:2718
#6  0x2858f5c7 in execute (op_array=0x810388c) at /home/mdev/cvs/php5/Zend/zend_execute.c:1227
#7  0x2857b7b0 in zend_execute_scripts (type=8, retval=0x0, file_count=3)
    at /home/mdev/cvs/php5/Zend/zend.c:996
#8  0x2853d0dc in php_execute_script (primary_file=0xbfbff944) at /home/mdev/cvs/php5/main/main.c:1699
#9  0x2859be4a in apache_php_module_main (r=0x809f038, display_source_mode=0)
    at /home/mdev/cvs/php5/sapi/apache/sapi_apache.c:55
#10 0x2859ce90 in send_php (r=0x809f038, display_source_mode=0, 
    filename=0x80a0b08 "/usr/local/www/data/bug.php") at /home/mdev/cvs/php5/sapi/apache/mod_php4.c:608
#11 0x2859cf03 in send_parsed_php (r=0x809f038) at /home/mdev/cvs/php5/sapi/apache/mod_php4.c:623
#12 0x8053688 in ap_invoke_handler (r=0x809f038) at http_config.c:518
#13 0x80631a9 in process_request_internal (r=0x809f038) at http_request.c:1308
#14 0x8063208 in ap_process_request (r=0x809f038) at http_request.c:1324
#15 0x805c63e in child_main (child_num_arg=0) at http_main.c:4689
#16 0x805c7d0 in make_child (s=0x8099038, slot=0, now=1043934649) at http_main.c:4813
#17 0x805c8ed in startup_children (number_to_start=5) at http_main.c:4895
#18 0x805cddc in standalone_main (argc=3, argv=0xbfbffc4c) at http_main.c:5203
#19 0x805d4d7 in main (argc=3, argv=0xbfbffc4c) at http_main.c:5566
(gdb) print ce
$1 = (zend_class_entry *) 0x0

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-03 07:39 UTC] moriyoshi@php.net
Verified.

BTW how come "bar" extends "man"?

 [2003-02-03 10:27 UTC] k.schroeder@php.net
tests/lang/bug21961.phpt failed on W2k server for latest PHP4-Win32-Stable snap. Reason: no SKIPIF for version < 5.0.0

---- EXPECTED OUTPUT
string(14) "The old Tavern"
---- ACTUAL OUTPUT
Parse error: parse error, unexpected $end in D:\work\php4\tests\lang\bug21961.php(44) : eval()'d code on line 1
bool(false)
---- FAILED

 [2003-02-10 04:04 UTC] zeev@php.net
Fixed.

The attached code was broken, by the way.  Attached is a fixed version of the code.

<?php

class man
{
        private $name;
        public $bars;

        function man()
        {
                $this->name = 'Mr. X';
                $this->bars = array();
        }

        function getdrunk($where)
        {
                $this->bars[] = new bar($where);
        }

        function getName()
        {
                return $this->name;
        }
}

class bar extends man
{
        var $name;

        function bar($w)
        {
                $this->name = $w;
        }


        function getName()
        {
                return $this->name;
        }

        function whosdrunk()
        {
                $who = get_parent_class($this);
                if($who == NULL)
                {
                        return 'nobody';
                }
                print "$who\n";
                eval('print '.$who.'::getName();');
        }
}

$x = new man;
$x->getdrunk('The old Tavern');
$x->bars[0]->whosdrunk();
?>

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 14:04:04 2025 UTC