Bug #51896 [NEW]: class a {function __construct(){new a();}} new a(); # - kills php

From: Date: Sun, 23 May 2010 22:33:10 +0000
Subject: Bug #51896 [NEW]: class a {function __construct(){new a();}} new a(); # - kills php
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-150746@lists.php.net to get a copy of this message
From:             
Operating system: Windows XP
PHP version:      5.3SVN-2010-05-23 (SVN)
Package:          Reproducible crash
Bug Type:         Bug
Bug description:class a {function __construct(){new a();}} new a(); # - kills php

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


-- 
Edit bug report at http://bugs.php.net/bug.php?id=51896&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=51896&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=51896&r=trysnapshot53
Try a snapshot (PHP 6.0):            http://bugs.php.net/fix.php?id=51896&r=trysnapshot60
Fixed in SVN:                        http://bugs.php.net/fix.php?id=51896&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51896&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=51896&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=51896&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=51896&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=51896&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=51896&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=51896&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=51896&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=51896&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=51896&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51896&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51896&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=51896&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=51896&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=51896&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=51896&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=51896&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#150746) next »