php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41421 Uncaught exception from a stream wrapper segfaults
Submitted: 2007-05-17 19:00 UTC Modified: 2007-05-18 11:56 UTC
From: hannes dot magnusson at gmail dot com Assigned: tony2001 (profile)
Status: Closed Package: Streams related
PHP Version: 5CVS-2007-05-17 (CVS) OS: FreeBSD
Private report: No CVE-ID: None
 [2007-05-17 19:00 UTC] hannes dot magnusson at gmail dot com
Description:
------------
Uncaught exceptions from a stream wrapper segfaults..

Reproduce code:
---------------
<?php
class wrapper {
        function stream_open() {
        return true;
    }
    function stream_eof() {
        throw new exception();
    }
}

stream_wrapper_register("wrap", "wrapper");
$fp = fopen("wrap://...", "r");
feof($fp);


Expected result:
----------------
Fatal error: Uncaught exception 'Exception' in %s:%d
Stack trace:
#0 [internal function]: wrapper->stream_eof()
#1 %s(%d): feof(Resource id #%d)
#2 {main}
  thrown in %s on line %d

Actual result:
--------------
Warning: feof(): wrapper::stream_eof is not implemented! Assuming EOF in /usr/src/php/5.2/wrapper.php on line 16

Fatal error: Uncaught exception 'Exception' in /usr/src/php/5.2/wrapper.php:7
Stack trace:
#0 [internal function]: wrapper->stream_eof()
#1 /usr/src/php/5.2/wrapper.php(13): feof(Resource id #6)
#2 {main}
  thrown in /usr/src/php/5.2/wrapper.php on line 7
Segmentation fault: 11 (core dumped)



#0  0x082f6191 in _zend_is_inconsistent (ht=0x5a5a5a76, file=0x8427ad4 "/usr/src/php/5.2/Zend/zend_hash.c", line=868) at /usr/src/php/5.2/Zend/zend_hash.c:53
#1  0x082f8523 in zend_hash_find (ht=0x5a5a5a76, arKey=0xbfbfe000 "stream_flush", nKeyLength=13, pData=0xbfbfe04c) at /usr/src/php/5.2/Zend/zend_hash.c:868
#2  0x0830aa6e in zend_std_get_method (object_ptr=0x8472440, method_name=0x8410b5b "stream_flush", method_len=12) at /usr/src/php/5.2/Zend/zend_object_handlers.c:767
#3  0x082e159e in zend_call_function (fci=0xbfbfe190, fci_cache=0x0) at /usr/src/php/5.2/Zend/zend_execute_API.c:783
#4  0x082e0cf7 in call_user_function_ex (function_table=0x0, object_pp=0x8472440, function_name=0xbfbfe210, retval_ptr_ptr=0xbfbfe20c, param_count=0, params=0x0, no_separation=0, 
    symbol_table=0x0) at /usr/src/php/5.2/Zend/zend_execute_API.c:602
#5  0x082c16ec in php_userstreamop_flush (stream=0x8471064) at /usr/src/php/5.2/main/streams/userspace.c:694
#6  0x082b7ac9 in _php_stream_flush (stream=0x8471064, closing=1) at /usr/src/php/5.2/main/streams/streams.c:1008
#7  0x082b6495 in _php_stream_free (stream=0x8471064, close_options=11) at /usr/src/php/5.2/main/streams/streams.c:321
#8  0x082b88f7 in stream_resource_regular_dtor (rsrc=0x847111c) at /usr/src/php/5.2/main/streams/streams.c:1369
#9  0x082f9b79 in list_entry_destructor (ptr=0x847111c) at /usr/src/php/5.2/Zend/zend_list.c:184
#10 0x082f78ee in zend_hash_del_key_or_index (ht=0x845da48, arKey=0x0, nKeyLength=0, h=6, flag=1) at /usr/src/php/5.2/Zend/zend_hash.c:497
#11 0x082f986b in _zend_list_delete (id=6) at /usr/src/php/5.2/Zend/zend_list.c:58
#12 0x082ebf86 in _zval_dtor_func (zvalue=0x847130c, __zend_filename=0x8425998 "/usr/src/php/5.2/Zend/zend_variables.h", __zend_lineno=35) at /usr/src/php/5.2/Zend/zend_variables.c:60
#13 0x082e0067 in _zval_dtor (zvalue=0x847130c, __zend_filename=0x842593c "/usr/src/php/5.2/Zend/zend_execute_API.c", __zend_lineno=414) at zend_variables.h:35
#14 0x082e0220 in _zval_ptr_dtor (zval_ptr=0x8471354, __zend_filename=0x84269a4 "/usr/src/php/5.2/Zend/zend_variables.c", __zend_lineno=175)
    at /usr/src/php/5.2/Zend/zend_execute_API.c:414
#15 0x082ec243 in _zval_ptr_dtor_wrapper (zval_ptr=0x8471354) at /usr/src/php/5.2/Zend/zend_variables.c:175
#16 0x082f7a0c in zend_hash_destroy (ht=0x8471268) at /usr/src/php/5.2/Zend/zend_hash.c:526
#17 0x082ebf43 in _zval_dtor_func (zvalue=0x84732fc, __zend_filename=0x8425998 "/usr/src/php/5.2/Zend/zend_variables.h", __zend_lineno=35) at /usr/src/php/5.2/Zend/zend_variables.c:43
#18 0x082e0067 in _zval_dtor (zvalue=0x84732fc, __zend_filename=0x842593c "/usr/src/php/5.2/Zend/zend_execute_API.c", __zend_lineno=414) at zend_variables.h:35
#19 0x082e0220 in _zval_ptr_dtor (zval_ptr=0x84713a4, __zend_filename=0x84269a4 "/usr/src/php/5.2/Zend/zend_variables.c", __zend_lineno=175)
    at /usr/src/php/5.2/Zend/zend_execute_API.c:414
#20 0x082ec243 in _zval_ptr_dtor_wrapper (zval_ptr=0x84713a4) at /usr/src/php/5.2/Zend/zend_variables.c:175
#21 0x082f7a0c in zend_hash_destroy (ht=0x8473024) at /usr/src/php/5.2/Zend/zend_hash.c:526
#22 0x082ebf43 in _zval_dtor_func (zvalue=0x8472fe8, __zend_filename=0x8425998 "/usr/src/php/5.2/Zend/zend_variables.h", __zend_lineno=35) at /usr/src/php/5.2/Zend/zend_variables.c:43
#23 0x082e0067 in _zval_dtor (zvalue=0x8472fe8, __zend_filename=0x842593c "/usr/src/php/5.2/Zend/zend_execute_API.c", __zend_lineno=414) at zend_variables.h:35
#24 0x082e0220 in _zval_ptr_dtor (zval_ptr=0x84713f8, __zend_filename=0x84269a4 "/usr/src/php/5.2/Zend/zend_variables.c", __zend_lineno=175)
    at /usr/src/php/5.2/Zend/zend_execute_API.c:414
#25 0x082ec243 in _zval_ptr_dtor_wrapper (zval_ptr=0x84713f8) at /usr/src/php/5.2/Zend/zend_variables.c:175
#26 0x082f7a0c in zend_hash_destroy (ht=0x8472c54) at /usr/src/php/5.2/Zend/zend_hash.c:526
#27 0x082ebf43 in _zval_dtor_func (zvalue=0x8470f28, __zend_filename=0x8425998 "/usr/src/php/5.2/Zend/zend_variables.h", __zend_lineno=35) at /usr/src/php/5.2/Zend/zend_variables.c:43
#28 0x082e0067 in _zval_dtor (zvalue=0x8470f28, __zend_filename=0x842593c "/usr/src/php/5.2/Zend/zend_execute_API.c", __zend_lineno=414) at zend_variables.h:35
#29 0x082e0220 in _zval_ptr_dtor (zval_ptr=0x8472c00, __zend_filename=0x84269a4 "/usr/src/php/5.2/Zend/zend_variables.c", __zend_lineno=175)
    at /usr/src/php/5.2/Zend/zend_execute_API.c:414
#30 0x082ec243 in _zval_ptr_dtor_wrapper (zval_ptr=0x8472c00) at /usr/src/php/5.2/Zend/zend_variables.c:175
#31 0x082f7a0c in zend_hash_destroy (ht=0x84711ac) at /usr/src/php/5.2/Zend/zend_hash.c:526
#32 0x0830857b in zend_object_std_dtor (object=0x8472688) at /usr/src/php/5.2/Zend/zend_objects.c:45
#33 0x083088b1 in zend_objects_free_object_storage (object=0x8472688) at /usr/src/php/5.2/Zend/zend_objects.c:122
#34 0x0830bb55 in zend_objects_store_free_object_storage (objects=0x845daf8) at /usr/src/php/5.2/Zend/zend_objects_API.c:89
#35 0x082dff29 in shutdown_executor () at /usr/src/php/5.2/Zend/zend_execute_API.c:299
#36 0x082ed632 in zend_deactivate () at /usr/src/php/5.2/Zend/zend.c:860
#37 0x082a4be8 in php_request_shutdown (dummy=0x0) at /usr/src/php/5.2/main/main.c:1317
#38 0x08354cc7 in main (argc=3, argv=0xbfbfebc0) at /usr/src/php/5.2/sapi/cli/php_cli.c:1319


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-18 11:56 UTC] tony2001@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 08:01:29 2024 UTC