ID: 21406 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Open +Status: Feedback Bug Type: Filesystem function related Operating System: linux PHP Version: 4CVS-2003-01-03 (dev) New Comment:
Thank you for this bug report. To properly diagnose the problem, we need a backtrace to see what is happening behind the scenes. To find out how to generate a backtrace, please read http://bugs.php.net/bugs-generating-backtrace.php Once you have generated a backtrace, please submit it to this bug report and change the status back to "Open". Thank you for helping us make PHP better. Always include a backtrace in reports of segfaults or bus errors (it saves a good 15 minutes or more of my time!) Thanks! Previous Comments: ------------------------------------------------------------------------ [2003-01-03 22:37:45] [EMAIL PROTECTED] Correction... Any two filters: stream_filter_append($fp, "rot13"); stream_filter_append($fp, "rot13"); or stream_filter_append($fp, "rot13"); stream_filter_append($fp, "default"); or stream_filter_append($fp, "default"); stream_filter_append($fp, "default"); all produce the same segfault when fclose()ing (presumably during the calls to write() or flush() in the filters). Note: "default" was previously registered using: stream_register_filter("default", "php_user_filter"); ------------------------------------------------------------------------ [2003-01-03 22:30:11] [EMAIL PROTECTED] The following code works fine when "stream_filter_append()" is called only once. Adding the second call causes a segfault when fclose() is called. <?php class rot13_filter extends php_user_filter { function read($length) { $tempstr = parent::read($length); for($i = 0; $i < strlen($tempstr); $i++) if (($tempstr[$i] >= 'A' AND $tempstr[$i] <= 'M') OR ($tempstr[$i] >= 'a' AND $tempstr[$i] <= 'm')) $tempstr[$i] = chr(ord($tempstr[$i]) + 13); else if (($tempstr[$i] >= 'N' AND $tempstr[$i] <= 'Z') OR ($tempstr[$i] >= 'n' AND $tempstr[$i] <= 'z')) $tempstr[$i] = chr(ord($tempstr[$i]) - 13); return $tempstr; } function write($data) { for($i = 0; $i < strlen($data); $i++) if (($data[$i] >= 'A' AND $data[$i] <= 'M') OR ($data[$i] >= 'a' AND $data[$i] <= 'm')) $data[$i] = chr(ord($data[$i]) + 13); else if (($data[$i] >= 'N' AND $data[$i] <= 'Z') OR ($data[$i] >= 'n' AND $data[$i] <= 'z')) $data[$i] = chr(ord($data[$i]) - 13); return parent::write($data); } } stream_register_filter("rot13", "rot13_filter") or die("Failed to register filter"); $fp = fopen("foo-bar.txt", "r"); stream_filter_append($fp, "rot13"); stream_filter_append($fp, "rot13"); fwrite($fp, "Line1\n"); fwrite($fp, "Word - 2\n"); fwrite($fp, "Easy As 123\n"); fclose($fp); ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=21406&edit=1