Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

php_stream_seek: Assertion `stream->position >= 0' failed. #26094

In review

Description

@lmaltsis

Description

The following code:

<?php
$c = fopen("data:,", 'rb');
fseek($c, -10, SEEK_END);
fseek($c, 1, SEEK_CUR);

Resulted in this output:

php: src/main/streams/streams.c:1433: php_stream_seek: Assertion `stream->position >= 0' failed.
Aborted

But I expected this output instead:
The second fseek simply returns with -1

It seems like the assert here https://github.com/php/php-src/blame/94519df8b69ad4c886789b983254695675de22c0/main/streams/streams.c#L1433 does not consider the sentinel value -1.

Execution on non-debug builds is not affected.

PHP Version

PHP 8.7.0-dev (cli) (built: Nov 29 2026 21:29:01) (NTS DEBUG)
Copyright © The PHP Group and Contributors
Zend Engine v4.7.0-dev, Copyright © Zend by Perforce
    with Zend OPcache v8.7.0-dev, Copyright ©, by Zend by Perforce

Operating System

Ubuntu 24.04

Activity

  1. devnexen commented on Dec 5, 2026

    @devnexen
    Member

    Hi @lmaltsis can you try building the last master branch with change I just committed ?

  2. lmaltsis commented on Dec 5, 2026

    @lmaltsis
    Author

    I've built from commit badd28d and I still get the same assertion failure on the debug build.

  3. devnexen commented on Dec 5, 2026

    @devnexen
    Member

    ah you re right, ok going to work on a fix.

  4. devnexen commented on Dec 5, 2026

    @devnexen
    Member

    nvm someone has, I think, already went in the right direction.

  5. linked a pull request that will close this issueFix/stream seek negative position #23907on Dec 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions