Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion failure in main/streams/streams.c #15908

Open
YuanchengJiang opened this issue Sep 16, 2024 · 1 comment · May be fixed by #15924
Open

Assertion failure in main/streams/streams.c #15908

YuanchengJiang opened this issue Sep 16, 2024 · 1 comment · May be fixed by #15924

Comments

@YuanchengJiang
Copy link

Description

The following code:

<?php
class TestStream { //data, empty data, empty data + eof
    public $context;
    private $s = 0;
    function stream_open($path, $mode, $options, &$opened_path) {
            return true;
    }
    function stream_read($count) {
        echo "Read done\n";
        if ($this->s++ == 0)
            return "a\nbb\ncc";
        return "";
    }
    function stream_eof() {
        return $this->s >= 2;
    }
}
stream_wrapper_register("test", "TestStream");
$f = fopen("test://", "r");
file_put_contents(1, $f, 1, $f);
?>

Resulted in this output:

/php-src/main/streams/streams.c:2214: _php_stream_open_wrapper_ex: Assertion `resolved_path == ((void *)0)' failed.
Aborted (core dumped)

PHP Version

PHP 8.4.0-dev

Operating System

ubuntu 22.04

@cmb69
Copy link
Member

cmb69 commented Sep 16, 2024

This happens to me only if a file "1" is in the include path.

Anyhow, see #15027. I think this assertion is too presumptious. @nielsdos, what do you think?

(By the way, I'm pretty surprised that include_path uses OnUpdateStringUnempty; that means you can have an empty path, although that is handled in php_resolve_path(); or is this just on Windows?)

@cmb69 cmb69 changed the title Core dumped in main/streams/streams.c Assertion failure in main/streams/streams.c Sep 16, 2024
@nielsdos nielsdos self-assigned this Sep 16, 2024
nielsdos added a commit to nielsdos/php-src that referenced this issue Sep 16, 2024
This was first reported as a leak in phpGH-15026, but was mistakingly
believed to be a false positive. Then an assertion was added and it got
triggered in phpGH-15908. This fixes the leak. Upon merging into master the
assertion should be removed as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants