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

Segmentation fault (access null pointer) in ext/spl/spl_directory.c #14687

Open
YuanchengJiang opened this issue Jun 27, 2024 · 3 comments
Open

Comments

@YuanchengJiang
Copy link

Description

The following code:

<?php
$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.zip';
$phar = new Phar($fname);
$script1_dataflow = $phar;
class HasDestructor {
  public function __destruct() {
    var_dump($GLOBALS['s']);
  }
}
$s = new SplObjectStorage();
$s[$script1_dataflow] = new HasDestructor();
$script2_connect=$s;

Resulted in this output:

object(SplObjectStorage)#2 (1) {
  ["storage":"SplObjectStorage":private]=>
  array(1) {
    [0]=>
    array(2) {
      ["obj"]=>
      Segmentation fault (core dumped)

ASan

/php-src/ext/spl/spl_directory.c:637:7: runtime error: member access within null pointer of type 'php_stream' (aka 'struct _php_stream')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /php-src/ext/spl/spl_directory.c:637:7

PHP Version

PHP 8.4.0-dev

Operating System

ubuntu 22.04

@devnexen
Copy link
Member

devnexen commented Jun 27, 2024

seems to be a case on reading on an already destroyed instance. I do not know really what s the most appropriate value to display e.g. false maybe for the glob part. cc @Girgias if you prefer to take of it yourself.

devnexen added a commit to devnexen/php-src that referenced this issue Jun 29, 2024
@Girgias Girgias self-assigned this Jun 29, 2024
@Girgias
Copy link
Member

Girgias commented Jun 29, 2024

I won't have time for a bit to look into those issues, will probably have more time when feature freeze is passed.

@devnexen
Copy link
Member

Yes I noticed it, thus I did a PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants