Open YuanchengJiang opened 1 month ago
Simplified reproducer:
require __DIR__ . '/ext/standard/tests/filters/filter_errors.inc';
class test_filter4 extends php_user_filter {
function filter($in, $out, &$consumed, $closing): int {
stream_bucket_new($this->stream, "42");
return PSFS_ERR_FATAL;
}
}
var_dump(stream_filter_register("test_filter4", "test_filter4"));
filter_errors_test("test_filter4", "42");
What appears to be happening is:
$stream
when leaving filter_errors_test()
test_filter4::filter()
is called while flushing the streamstream_bucket_new()
. $stream
is captured by the exception traceWe should avoid freeing the resource if its refcount is non-zero after dtor, but it has already been removed from the rsrc list at this point so it would leak. Also, if we do not free it immediately after dtor we should probably avoid calling dtor a second time later.
Conversion to objects would probably fix this.
Description
The following code:
Resulted in this output:
To reproduce:
PHP Version
PHP 8.4.0-dev
Operating System
ubuntu 22.04