ID:               32171
 User updated by:  jr at terragate dot net
 Reported By:      jr at terragate dot net
-Status:           Feedback
+Status:           Open
 Bug Type:         SPL related
 Operating System: x86 linux
 PHP Version:      5.0.3
 New Comment:

I already tested the bug against yesterdays snapshot of 
5.0.x.

Using the 5.1.0 snap does not resolve the exception 
issue. 

I will test the instanceof segfault on monday against 
the 5.1 branch.

Maybe I should create a seperate bug for it.

 

voyager:~/Downloads/php5-200503041530/result/bin jr$ 
uname -a
Darwin voyager.starbase12.sfn 7.8.0 Darwin Kernel 
Version 7.8.0: Wed Dec 22 14:26:17 PST 2004; root:xnu/
xnu-517.11.1.obj~1/RELEASE_PPC  Power Macintosh powerpc
voyager:~/Downloads/php5-200503041530/result/bin jr$ ./
php -v
PHP 5.1.0-dev (cgi) (built: Mar  4 2005 18:33:26) 
(DEBUG)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.1.0-dev, Copyright (c) 1998-2004 Zend 
Technologies
voyager:~/Downloads/php5-200503041530/result/bin jr$ ./
php test.php 
Content-type: text/html
X-Powered-By: PHP/5.1.0-dev

<br />
<b>Fatal error</b>:  Uncaught exception 'Exception' with 
message 'is_a(): Deprecated. Please use the instanceof 
operator' in /Volumes/Data/Users/jr/Downloads/php5
-200503041530/result/bin/test.php:6
Stack trace:
#0 /Volumes/Data/Users/jr/Downloads/php5-200503041530/
result/bin/test.php(12): StreamWrapper-
>dir_opendir(NULL, 'AKnownOrUnknown...')
#1 /Volumes/Data/Users/jr/Downloads/php5-200503041530/
result/bin/test.php(12): DirectoryIterator-
>__construct('test://path/', 4)
#2 {main}
  thrown in <b>/Volumes/Data/Users/jr/Downloads/php5
-200503041530/result/bin/test.php</b> on line <b>6</
b><br />
/Volumes/Data/Users/jr/Downloads/php5-200503041530/
result/bin/test.php(6) : Fatal error - Uncaught 
exception 'Exception' with message 'is_a(): Deprecated. 
Please use the instanceof operator' in /Volumes/Data/
Users/jr/Downloads/php5-200503041530/result/bin/
test.php:6
Stack trace:
#0 /Volumes/Data/Users/jr/Downloads/php5-200503041530/
result/bin/test.php(12): StreamWrapper-
>dir_opendir(NULL, 'AKnownOrUnknown...')
#1 /Volumes/Data/Users/jr/Downloads/php5-200503041530/
result/bin/test.php(12): DirectoryIterator-
>__construct('test://path/', 4)
#2 {main}
  thrown


Previous Comments:
------------------------------------------------------------------------

[2005-03-04 16:34:34] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip



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

[2005-03-03 17:13:03] jr at terragate dot net

After digging a while in the PHP source I found the reason for the
thrown exception.

The SPL sets the php error handling mode to EH_THROW. 

But currently php_error_cb throws everything as exception, even notices
(E_NOTICE), warnings (E_WARNING) and strict warnings caused by
E_STRICT.

IMHO those shouldn't be thrown as exception. 

I've made a path that fixes this. E_NOTICE, E_WARNING and E_STRICT will
be handled the same way as in EH_NORMAL.

Probably E_USER_NOTICE and E_USER_WARNING should be added.

http://www.terragate.net/~jr/no_notices_and_warnings_as_exception.diff

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

[2005-03-03 15:05:51] jr at terragate dot net

I was able to create a smaller example for the exception:

<?php

class StreamWrapper
{
  public function dir_opendir($path, $options) {
    return is_a(null, 'AKnownOrUnknownClass');
  }

}

stream_wrapper_register('test', 'StreamWrapper');
$it = new DirectoryIterator('test://path/');

?>

This will raise the following exception:

Fatal error: Uncaught exception 'Exception' with message 'is_a():
Deprecated. Please use the instanceof operator' in
/var/www/localhost/htdocs/splexception.php:6
Stack trace:
#0 /var/www/localhost/htdocs/splexception.php(6): is_a(NULL,
'AKnownOrUnknown...')
#1 /var/www/localhost/htdocs/splexception.php(13):
StreamWrapper->dir_opendir('test://path/', 4)
#2 /var/www/localhost/htdocs/splexception.php(13):
DirectoryIterator->__construct('test://path/')
#3 {main}
  thrown in /var/www/localhost/htdocs/splexception.php on line 6


This problem does not occur when using opendir so this seems to be SPL
related. 

Category changed accordingly 

I wasn't able to reproduce the instanceof crash with this small
snippet.

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

[2005-03-03 12:37:04] jr at terragate dot net

Description:
------------
PEAR's HTTP_WebDAV_Client causes PHP 5 to trow a deprecated warning as
Exception:

Fatal error: Uncaught exception 'Exception' with message 'is_a():
Deprecated. Please use the instanceof operator' in
/usr/lib/php/PEAR.php:248
Stack trace:
#0 /usr/lib/php/PEAR.php(248): is_a(true, 'PEAR_Error')
#1 /usr/lib/php/HTTP/Request.php(591): HTTP_Request->isError(true)
#2 /usr/lib/php/HTTP/WebDAV/Client/Stream.php(796):
HTTP_Request->sendRequest()
#3 /usr/lib/php/HTTP/WebDAV/Client/Stream.php(446):
HTTP_WebDAV_Client_Stream->_check_options()
#4 /var/www/localhost/htdocs/crash.php(5):
HTTP_WebDAV_Client_Stream->dir_opendir('webdav://test:t...', 4)
#5 /var/www/localhost/htdocs/crash.php(5):
DirectoryIterator->__construct('webdav://test:t...')
#6 {main}
  thrown in /usr/lib/php/PEAR.php on line 248

Is this a bug or a feature (deprecation messages thrown as
Exceptions)?

Changing the is_a in PEAR.php to instanceof causes a segfault.

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

require_once('HTTP/WebDAV/Client.php');

$it = new DirectoryIterator('webdav://test:[EMAIL PROTECTED]/');

echo 'Done';

?>

for the 'deprecation exception' and a additional change for the
segfault:

PEAR.php ~line 248:

if ($data instanceof PEAR_Error) {

instead of:

if (is_a($data, 'PEAR_Error')) {

This requires a valid webdav URL (I can provide one if necessary).

Expected result:
----------------
Clean shutdown

Actual result:
--------------
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 22648)]
Done
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 22648)]
0x00000019 in ?? ()
#0  0x00000019 in ?? ()
#1  0x0829ca06 in _php_stream_free (stream=0x8652714, close_options=3)
    at
/var/tmp/portage/php-5.0.3/work/php-5.0.3/main/streams/streams.c:351
#2  0x081b0d74 in spl_ce_dir_object_free_storage (object=0x85e067c)
    at
/var/tmp/portage/php-5.0.3/work/php-5.0.3/ext/spl/spl_directory.c:66
#3  0x082e939d in zend_objects_store_del_ref (zobject=0x85f4430)
    at
/var/tmp/portage/php-5.0.3/work/php-5.0.3/Zend/zend_objects_API.c:159
#4  0x082cc90f in _zval_dtor (zvalue=0x85da6ac,
    __zend_filename=0x84a0800
"/var/tmp/portage/php-5.0.3/work/php-5.0.3/Zend/zend_execute_API.c",
__zend_lineno=392)
    at
/var/tmp/portage/php-5.0.3/work/php-5.0.3/Zend/zend_variables.c:61
#5  0x082c19cb in _zval_ptr_dtor (zval_ptr=0x85ddda8,
    __zend_filename=0x85f4430 "xA_\b\uffff\001^\b",
__zend_lineno=140461104)
    at
/var/tmp/portage/php-5.0.3/work/php-5.0.3/Zend/zend_execute_API.c:392
#6  0x082ccce2 in _zval_ptr_dtor_wrapper (zval_ptr=0x85f4430)
    at
/var/tmp/portage/php-5.0.3/work/php-5.0.3/Zend/zend_variables.c:193
#7  0x082d976f in zend_hash_apply_deleter (ht=0x85131b0, p=0x85ddd9c)
    at /var/tmp/portage/php-5.0.3/work/php-5.0.3/Zend/zend_hash.c:574
#8  0x082d707c in zend_hash_graceful_reverse_destroy (ht=0x85131b0)
    at /var/tmp/portage/php-5.0.3/work/php-5.0.3/Zend/zend_hash.c:640
#9  0x082c123a in shutdown_executor ()
    at
/var/tmp/portage/php-5.0.3/work/php-5.0.3/Zend/zend_execute_API.c:208
#10 0x082cddde in zend_deactivate ()
    at /var/tmp/portage/php-5.0.3/work/php-5.0.3/Zend/zend.c:818
#11 0x08288352 in php_request_shutdown (dummy=0x0)
    at /var/tmp/portage/php-5.0.3/work/php-5.0.3/main/main.c:1212
#12 0x083111b7 in main (argc=2, argv=0xbffff844)
    at
/var/tmp/portage/php-5.0.3/work/php-5.0.3/sapi/cli/php_cli.c:1046



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


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

Reply via email to