php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31137 stream_filter_remove() segfaults when stream is already closed
Submitted: 2004-12-16 22:17 UTC Modified: 2005-03-29 06:20 UTC
From: tony2001 at phpclub dot net Assigned: pollita (profile)
Status: Closed Package: Filesystem function related
PHP Version: 5CVS-2004-12-16 OS: *
Private report: No CVE-ID: None
 [2004-12-16 22:17 UTC] tony2001 at phpclub dot net
Description:
------------
Segfault when trying to remove stream filter *after* closing the stream itself.
Wez, please, look into this, I don't have much time to debug it myself ATM.

Reproduce code:
---------------
<?
//register some filter, it doesn't matter
stream_filter_register("f", "php_user_filter");

//open a stream
$fp = fopen("somefile.tmp", "w");

//append filter to the stream
$filter = stream_filter_append($fp, "f");

//write something
fwrite($fp, "something\n");

//we're closing the stream, but the filter is still there
fclose($fp);

//segfault when trying to remove filter
stream_filter_remove($filter);
?>

Expected result:
----------------
.

Actual result:
--------------
Program received signal SIGSEGV, Segmentation fault.
0x08141ef2 in _php_stream_filter_flush (filter=0x82c54bc, finish=1) at /home/dev/php-src/main/streams/filter.c:418
418             if (!filter->chain || !filter->chain->stream) {
(gdb) bt
#0  0x08141ef2 in _php_stream_filter_flush (filter=0x82c54bc, finish=1) at /home/dev/php-src/main/streams/filter.c:418
#1  0x081213c5 in zif_stream_filter_remove (ht=1, return_value=0x82b2bfc, this_ptr=0x0, return_value_used=0)
    at /home/dev/php-src/ext/standard/streamsfuncs.c:1143
#2  0x0818fb03 in zend_do_fcall_common_helper_SPEC (execute_data=0xbfffd3c0) at zend_vm_execute.h:155
#3  0x08192531 in ZEND_DO_FCALL_SPEC_CONST_HANDLER (execute_data=0xbfffd3c0) at zend_vm_execute.h:1514
#4  0x0818f81b in execute (op_array=0x82c0814) at zend_vm_execute.h:58
#5  0x0816cba7 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /home/dev/php-src/Zend/zend.c:1062
#6  0x0812ce37 in php_execute_script (primary_file=0xbffff7d0) at /home/dev/php-src/main/main.c:1639
#7  0x081dcb25 in main (argc=2, argv=0xbffff864) at /home/dev/php-src/sapi/cli/php_cli.c:943
#8  0x420157a4 in __libc_start_main () from /lib/tls/libc.so.6

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-29 01:11 UTC] sniper@php.net
Assigning to correct developer. (And Sara: this is still broken in HEAD :)

 [2005-03-29 06:20 UTC] pollita@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.

Thanks for keeping me honest Jani
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 06:01:32 2024 UTC