php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77263 Segfault when using 2 RecursiveFilterIterator
Submitted: 2018-12-07 16:03 UTC Modified: 2018-12-08 14:24 UTC
Votes:4
Avg. Score:5.0 ± 0.0
Reproduced:4 of 4 (100.0%)
Same Version:4 (100.0%)
Same OS:4 (100.0%)
From: yani at iliev dot me Assigned: dmitry (profile)
Status: Closed Package: Reproducible crash
PHP Version: 7.3.0 OS: Any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: yani at iliev dot me
New email:
PHP Version: OS:

 

 [2018-12-07 16:03 UTC] yani at iliev dot me
Description:
------------
When two RecursiveFilterIterator are added to RecursiveDirectoryIterator it results in a segfault. The same code works in PHP 7.2.x and below

Test script:
---------------
<?php

mkdir("/tmp/dir");
mkdir("/tmp/dir/subdir");
touch("/tmp/dir/file1");
touch("/tmp/dir/subdir/file2");

class Filter1 extends RecursiveFilterIterator {
    public function accept() { return $this->getInnerIterator()->getSubPathname() != ''; }
}

class Filter2 extends RecursiveFilterIterator {
    public function accept() { return $this->getInnerIterator()->getSubPathname() != ' '; }
}

$iterator = new RecursiveDirectoryIterator( '/tmp', FilesystemIterator::SKIP_DOTS );

$iterator = new Filter1( $iterator );

$iterator = new Filter2( $iterator );

$iterator = new RecursiveIteratorIterator( $iterator, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD );

foreach ( $iterator as $item ) {
    echo  $iterator->getSubPathName() . PHP_EOL;
}

Expected result:
----------------
dir/file1
dir/subdir/file2

Actual result:
--------------
dir/file1

Process exited with code 139.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-12-07 16:34 UTC] yani at iliev dot me
-Summary: Segfaullt when using 2 RecursiveFilterIterator +Summary: Segfault when using 2 RecursiveFilterIterator -Operating System: Any +Operating System: Windows 10 Pro x64 -PHP Version: 7.3.0 +PHP Version: 7.2.6
 [2018-12-07 16:34 UTC] yani at iliev dot me
Fixed a typo in the title
 [2018-12-07 16:48 UTC] yani at iliev dot me
-Operating System: Windows 10 Pro x64 +Operating System: Any -PHP Version: 7.2.6 +PHP Version: 7.3.0
 [2018-12-07 16:48 UTC] yani at iliev dot me
PHP Version should be 7.3.0
 [2018-12-08 14:24 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: dmitry
 [2018-12-08 14:24 UTC] cmb@php.net
Apparently, this regression has been introduced by commit
40551e0[1].  Dmitry, could you please have a look at this issue?

[1] <http://git.php.net/?p=php-src.git;a=commit;h=40551e0255b3ad773dcc058305fa5a61c6ae7f39>
 [2019-01-14 10:21 UTC] dmitry@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=920450534ea7bc8852509d159d488a62f8032c80
Log: Fixed bug #77263 (Segfault when using 2 RecursiveFilterIterator)
 [2019-01-14 10:21 UTC] dmitry@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Jan 17 19:01:26 2019 UTC