php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51896 class a {function __construct(){new a();}} new a(); # - kills php
Submitted: 2010-05-24 00:32 UTC Modified: 2010-05-24 00:37 UTC
From: RocketInABog at techno-monks dot net Assigned:
Status: Not a bug Package: Reproducible crash
PHP Version: 5.3SVN-2010-05-23 (SVN) OS: Windows XP
Private report: No CVE-ID: None
 [2010-05-24 00:32 UTC] RocketInABog at techno-monks dot net
Description:
------------
I know it's wrong to try to instantiate a class within it's own constructor,
yet I thought that I should report the crashing of the php interpreter.
Perhaps this case may expose an area of the interpreter that may cause other problems.

Here is a sample script.

<?php class a {function __construct(){new a();}} new a(); # - kills php ?>


Here is the message produced (with php 5.3.2):

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 261904 bytes) in M:\workspace\html\directAbrasives\lib\t.php on line 1


Here is my php version:

PHP 5.3.2 (cli) (built: Mar  3 2010 20:47:01) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies


Running this code on PHP 5.2 didn't generate any message at all.

Also, I tried a catching exceptions, yet it appears that none are thrown in this case.

I am operating on WindowsXP.


Cheers.

-g


Test script:
---------------
<?php class a {function __construct(){new a();}} new a(); # - kills php ?>

Expected result:
----------------
Some kind of error message with a line number saying you can't do this.


Actual result:
--------------
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 261904 bytes) in M:\workspace\html\directAbrasives\lib\t.php on line 1


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-24 00:37 UTC] felipe@php.net
-Status: Open +Status: Bogus
 [2010-05-24 00:37 UTC] felipe@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


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