php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73471 PHP freezes with AppendIterator
Submitted: 2016-11-07 07:43 UTC Modified: 2017-05-01 05:47 UTC
Votes:3
Avg. Score:4.3 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (33.3%)
From: saschaprolic at googlemail dot com Assigned: jhdxr (profile)
Status: Closed Package: SPL related
PHP Version: 5.6 OS: Linux 4.4.0-43-generic Ubuntu
Private report: No CVE-ID: None
 [2016-11-07 07:43 UTC] saschaprolic at googlemail dot com
Description:
------------
PHP freezes when I use the append iterator. I could not create an isolated script, where only this problem is covered, yet.

But here is how to reproduce and how to bypass it, take a look at the following change in my PR to prooph/event-store:

https://github.com/prooph/event-store/pull/210

I hope this helps you guys already to isolate the problem. Either way, you can always clone our repository and run the tests with that patch excluded, so you will see the same in real action.


Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-07 07:45 UTC] saschaprolic at googlemail dot com
The change is here: https://github.com/prooph/event-store/pull/210/commits/61465535e6acc657c80a1bab7ab909470cf579e8
 [2016-11-07 08:23 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2016-11-07 08:23 UTC] requinix@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

"Freezes"? Could it be an infinite loop somewhere? Use a debugger to find out exactly where and when the problem is.
 [2016-11-07 13:22 UTC] saschaprolic at googlemail dot com
-Status: Feedback +Status: Open
 [2016-11-07 13:22 UTC] saschaprolic at googlemail dot com
I tried to create an isolated test script where you don't need to clone the event-store repository, and run the phpunit tests yourself. Unfortunately I was not successful so far. But I gave you the required links, so you actually are able to reproduce this issue, it's just a little more work than running a simple 20 line test-script.

PHP hangs forever exactly at this line:
https://github.com/prooph/event-store/pull/210/commits/61465535e6acc657c80a1bab7ab909470cf579e8#diff-cded286a30dea4e80fa00f01cfa1a8fbL73

It does not crash, so maybe it's an infinite loop, but not in the userland code, but in PHP itself.
 [2016-11-08 10:03 UTC] saschaprolic at googlemail dot com
Here is the shortest script to reproduce the issue.

<?php

$iterator1 = new \AppendIterator();
$iterator2 = new \AppendIterator();

$events = new \ArrayIterator(['event']);

$iterator1->append($events);
$iterator2->append($events);

// without this foreach, i will not hang
foreach ($iterator2 as $event) {
}

$events = new \ArrayIterator(['event']);
$iterator1->append($events);
$iterator2->append($events);
 [2016-11-08 10:21 UTC] saschaprolic at googlemail dot com
This bug is also there in PHP 5.6 and 7.0!
See also this test-script:

<?php

$iterator1 = new \AppendIterator();
$iterator2 = new \AppendIterator();

$events = new \ArrayIterator(['event']);

$iterator1->append($events);
$iterator2->append($events);

// without this foreach, i will not hang
foreach ($iterator2 as $event) {
}

$iterator1->append(new \ArrayIterator());
 [2016-11-08 10:47 UTC] hello at bweston dot me
Narrowed it down to this while loop.

https://github.com/php/php-src/blob/PHP-7.1.0RC3/ext/spl/spl_iterators.c#L3379
 [2016-11-08 22:42 UTC] requinix@php.net
-Status: Open +Status: Verified
 [2016-11-13 07:13 UTC] krakjoe@php.net
-PHP Version: 7.1.0RC5 +PHP Version: 5.6
 [2016-11-13 07:13 UTC] krakjoe@php.net
Changed version, so far as I can see, this has been a bug since 5.2 ...
 [2017-05-01 05:47 UTC] jhdxr@php.net
-Assigned To: +Assigned To: jhdxr
 [2017-05-01 05:47 UTC] jhdxr@php.net
-Status: Verified +Status: Assigned
 [2017-06-22 10:58 UTC] krakjoe@php.net
Automatic comment on behalf of jhdxr
Revision: http://git.php.net/?p=php-src.git;a=commit;h=81c2a4b9ba0816a0bda4f004aeca634ad8b58970
Log: fix bug #73471 PHP freezes with AppendIterator
 [2017-06-22 10:58 UTC] krakjoe@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC