#31137 [NEW]: stream_filter_remove() segfaults when stream is already closed

From: Date: Thu, 16 Dec 2004 21:17:02 +0000
Subject: #31137 [NEW]: stream_filter_remove() segfaults when stream is already closed
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-70405@lists.php.net to get a copy of this message
From:             tony2001 at phpclub dot net
Operating system: Linux
PHP version:      5CVS-2004-12-16 (dev)
PHP Bug Type:     Filesystem function related
Bug description:  stream_filter_remove() segfaults when stream is already closed

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

-- 
Edit bug report at http://bugs.php.net/?id=31137&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=31137&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31137&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31137&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=31137&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=31137&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=31137&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=31137&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=31137&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=31137&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=31137&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=31137&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=31137&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=31137&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=31137&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=31137&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=31137&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=31137&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=31137&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=31137&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=31137&r=mysqlcfg


Thread (5 messages)

« previous php.bugs (#70405) next »