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

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.


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

[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