php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30922 reflective functions crash PHP when interfaces extend themselves
Submitted: 2004-11-28 18:40 UTC Modified: 2004-12-06 12:54 UTC
From: Jason at AMP-design dot net Assigned: andi (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.0.2 OS: Windows 2003
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: Jason at AMP-design dot net
New email:
PHP Version: OS:

 

 [2004-11-28 18:40 UTC] Jason at AMP-design dot net
Description:
------------
When a interface extends it's self, it will cause PHP to crash when reflective language features such as instanceOf, is_a are used on objects that implement the recursive interface.

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

interface RecurisiveFooFar extends RecurisiveFooFar {}
class A implements RecurisiveFooFar {}

$a = new A();
var_dump($a instanceOf A);

?>

Expected result:
----------------
Something like ...

Fatal Error: interface can not extend it's self on line __LINE__ in __FILE__

Actual result:
--------------
PHP Crashes. Apache log shows this activity.

[Sun Nov 28 15:47:43 2004] [notice] Parent: child process exited with status 128 -- Restarting.
[Sun Nov 28 15:47:43 2004] [notice] Parent: Created child process 3932
[Sun Nov 28 15:47:43 2004] [notice] Child 3932: Child process is running
[Sun Nov 28 15:47:43 2004] [notice] Child 3932: Acquired the start mutex.
[Sun Nov 28 15:47:43 2004] [notice] Child 3932: Starting 250 worker threads.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-11-28 18:49 UTC] tony2001@php.net
Reproduced with HEAD too.
Please, review the patch below:

Index: zend_compile.c
===================================================================
RCS file: /repository/ZendEngine2/zend_compile.c,v
retrieving revision 1.600
diff -u -r1.600 zend_compile.c
--- zend_compile.c      16 Oct 2004 23:17:58 -0000      1.600
+++ zend_compile.c      28 Nov 2004 17:48:34 -0000
@@ -1997,6 +1997,10 @@
        if (!(ce->ce_flags & ZEND_ACC_INTERFACE) && iface->interface_gets_implemented && iface->interface_gets_implemented(iface, ce TSRMLS_CC) == FAILURE) {
                zend_error(E_CORE_ERROR, "Class %s could not implement interface %s", ce->name, iface->name);
        }
+
+       if (ce == iface) {
+               zend_error(E_CORE_ERROR, "Interface %s cannot not implement itself", ce->name);
+       }
 }
 [2004-12-06 12:54 UTC] dmitry@php.net
Fixed in CVS HEAD and PHP_5_0.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:29 2024 UTC