Bug #73300 [Nab]: crashe on late state binding call parent non static method

From: Date: Wed, 12 Oct 2016 15:33:31 +0000
Subject: Bug #73300 [Nab]: crashe on late state binding call parent non static method
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-204641@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73300&edit=1

 ID:                 73300
 Updated by:         cmb@php.net
 Reported by:        roman4e at gmail dot com
 Summary:            crashe on late state binding call parent non static
                     method
 Status:             Not a bug
 Type:               Bug
 Package:            Reproducible crash
 Operating System:   Linux mint
 PHP Version:        7.0.11
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

PHP does not check for infinite recursion for performance reasons.
See also <http://php.net/manual/en/functions.user-defined.php>.

You can install Xdebug in your development environment(s), and set
xdebug.max_nesting_level to an appropriate value.


Previous Comments:
------------------------------------------------------------------------
[2016-10-12 14:34:42] roman4e at gmail dot com

I think it should not be a segfault error but fatal error like "memory exceed" or too deep
recursion, does it?

------------------------------------------------------------------------
[2016-10-12 14:09:59] cmb@php.net

This is expected behavior, because the script causes infinite
recursion, see <https://3v4l.org/c1lM1>, what is a
programmer
error.

------------------------------------------------------------------------
[2016-10-12 09:55:34] roman4e at gmail dot com

Description:
------------
Trying to access parent method which overloaded in child with late state binding gets segmentation
fault.

Test script:
---------------
<?php

class A {
  protected $data = [1,2,3,5];

  public function data() { return $this->data; }
}

class B extends A {
  protected $data = [5,6,7,89];
  public function data() { return static::data(); }
}

$b = new B();
var_dump($b->data());


Expected result:
----------------
Do not known

Actual result:
--------------
Segmentation fault



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=73300&edit=1


Thread (4 messages)

« previous php.bugs (#204641) next »