php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39196 Endless loop when for exception thrown on E_RECOVERABLE_ERROR
Submitted: 2006-10-19 11:55 UTC Modified: 2006-10-19 13:53 UTC
From: kore@php.net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.0RC5 OS: Linux 2.6.18-gentoo
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: kore@php.net
New email:
PHP Version: OS:

 

 [2006-10-19 11:55 UTC] kore@php.net
Description:
------------
When the error thrown by SWFMovie::save is catched by the error handler and "converted" to an exceptions this results in an endless loop.

Tested with 5.2-RC5 and 5.2-RC6-dev.

I tested this with another E_RECOVERABLE_ERROR thrown by a wrong return value of __toString, which does not cause the endless loop, so that it is perhaps ming related.

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

function errorHandler($errno, $errstr, $errfile, $errline)
{
    throw new Exception( 'An error occured.' );
}

set_error_handler( 'errorHandler' );

$movie = new SWFMovie();

$image = new SWFBitmap( file_get_contents( 'http://kore.phpugdo.de/jpg.jpeg' ) );
$object = $movie->add( $image );

$movie->save( 'test.swf' );


Expected result:
----------------
PHP Fatal error:  Uncaught exception 'Exception' with message 'An error occured.' in /path/file.php

Actual result:
--------------
Endless loop

Shortened backtrace after a SIGINT, which made me assume, that is a problem in the scripting engine:

#0  0x083ea725 in _zend_mm_alloc_int (heap=0x871b3f8, size=16, __zend_filename=0x86b89e4 "/home/kore/bin/php/php-5.2-cvs/php-src/Zend/zend.c", __zend_lineno=962, 
    __zend_orig_filename=0x0, __zend_orig_lineno=0) at /home/kore/bin/php/php-5.2-cvs/php-src/Zend/zend_alloc.c:1080
#1  0x083eb91a in _emalloc (size=16, __zend_filename=0x86b89e4 "/home/kore/bin/php/php-5.2-cvs/php-src/Zend/zend.c", __zend_lineno=962, __zend_orig_filename=0x0, 
    __zend_orig_lineno=0) at /home/kore/bin/php/php-5.2-cvs/php-src/Zend/zend_alloc.c:1640
#2  0x08406d45 in zend_error (type=4096, format=0x869d417 "%s") at /home/kore/bin/php/php-5.2-cvs/php-src/Zend/zend.c:962
#3  0x083b6a1c in php_verror (docref=0x88478b4 'Z' <repeats 79 times>, "\204&#65533;\217*Zu", params=0x869cee5 "", type=4096, format=0x86639f9 "%s", 
    args=0xbf87997c "4q\204\bp&#65533;\207\bXZ") at /home/kore/bin/php/php-5.2-cvs/php-src/main/main.c:584
#4  0x083b6a81 in php_error_docref0 (docref=0x0, type=4096, format=0x86639f9 "%s") at /home/kore/bin/php/php-5.2-cvs/php-src/main/main.c:596
#5  0x081d7433 in php_ming_error (msg=0xb7d7ffa0 "Unexpected end of Jpeg file (EOF found)!") at /home/kore/bin/php/php-5.2-cvs/php-src/ext/ming/ming.c:4027
#6  0xb7d64403 in methodWriteJpegFile () from /usr/lib/libming.so.0

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-19 13:53 UTC] tony2001@php.net
Not PHP problem. 
Code like this is supposed to result in endless loop (ming-0.3.0/src/blocks/jpeg.c:142):
for ( ;; )
{
    if ( SWFInput_getChar(input) != JPEG_MARKER )
        SWF_error("Jpeg marker not found where expected!");

    <skip>
}

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 18:01:33 2025 UTC