Skip to content

unreachable program point: mime_content_type() #17164

Closed as not planned
Closed as not planned

Description

@chongwick

Description

The following code:

<?php
var_dump(mime_content_type('./..'));
?>

Resulted in this output:

/home/dan/php-src/main/streams/plain_wrapper.c:290:4: runtime error: execution reached an unreachable program point

PHP Version

8.4.1

Operating System

No response

Activity

  1. cmb69 commented on Dec 15, 2024

    @cmb69
    Member

    Apparently, the following assertion is hit:

    ZEND_ASSERT(zend_lseek(self->fd, 0, SEEK_CUR) == 0);

    I cannot reproduce on Windows, probably due to

    #ifdef PHP_WIN32
    if (php_stream_stat_path_ex(buffer, 0, &ssb, context) == SUCCESS) {
    if (ssb.sb.st_mode & S_IFDIR) {
    ret_val = mime_directory;
    goto common;
    }
    }
    #endif

  2. ndossche commented on Dec 15, 2024

    @ndossche
    Member

    This doesn't reproduce on my system (Linux). What OS did you use, and what configuration options did you use? I tried debug builds with both GCC and Clang, and also tried a release build with GCC.

  3. cmb69 commented on Dec 15, 2024

    @cmb69
    Member

    It could also be helpful to see the stack backtrace.

  4. chongwick commented on Dec 17, 2024

    @chongwick
    Author

    @nielsdos This is the release version of 8.4.1 with only the "--enable-undefined-sanitizer" option on Ubuntu 22.04. Oddly, this only seems to trigger inside of a Singularity container.
    @cmb69 I have a stupid question... how?

  5. ndossche commented on Dec 17, 2024

    @ndossche
    Member

    Can you please retry on the last PHP-8.4 branch with a debug build and UBSAN?
    You can then enable UBSAN stacktraces using an environment variable. I.e. export UBSAN_OPTIONS="print_stacktrack=true"

  6. chongwick commented on Dec 18, 2024

    @chongwick
    Author

    8.4.2 ubsan debug:
    ubsanphp842: /home/dan/php-src/main/streams/plain_wrapper.c:290: _php_stream_fopen_from_fd: Assertion `lseek(self->fd, 0, 1) == 0' failed.
    Aborted (core dumped)

    (There was no further output from stack trace)

  7. cmb69 commented on Dec 18, 2024

    @cmb69
    Member

    The only way this assertion could be triggered is that either lseek(2) fails (returns -1), or that the stream is not already zero-positioned. Neither should happen.

    Anyhow, I don't think this is particularly related to ext/fileinfo; the following should likely behave the same:

    <?php
    var_dump(fopen('./..', "r"));
  8. chongwick commented on Dec 18, 2024

    @chongwick
    Author

    It does. Also, var_dump() is not necessary in either case.

  9. ndossche commented on Dec 18, 2024

    @ndossche
    Member

    The container that @chongwick is probably crucial. Likely some sort of security mechanism is preventing seeking on that.

  10. chongwick commented on Dec 18, 2024

    @chongwick
    Author

    @nielsdos I would say not the container rather the cluster.

  11. added theissue type on Feb 5, 2025
  12. marked core dump #19742 as a duplicate of this issue on Sep 6, 2025
  13. ndossche commented on Oct 25, 2026

    @ndossche
    Member

    We never managed to reproduce this and there's not enough info to replicate the environment to be able to replicate this. Closing as non-reproducible.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions