Bug #75786 [Opn]: segfault when using spread operator on generator passed by reference
| From: | chris at kruining dot eu | Date: | Tue, 09 Jan 2018 15:51:29 +0000 |
| Subject: | Bug #75786 [Opn]: segfault when using spread operator on generator passed by reference | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-213444@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75786&edit=1
ID: 75786
User updated by: chris at kruining dot eu
Reported by: chris at kruining dot eu
-Summary: PHP 7.1.12-1 (Debian does not yet have 7.1.13 or
7.2.1)
+Summary: segfault when using spread operator on generator
passed by reference
Status: Open
Type: Bug
Package: *General Issues
Operating System: Debian - buster
-PHP Version: 7.1.13
+PHP Version: PHP 7.1.12-1 (Debian does not yet have 7.1.13 or
7.2.1)
Block user comment: N
Private report: N
New Comment:
updated the summary
Previous Comments:
------------------------------------------------------------------------
[2018-01-09 15:49:11] chris at kruining dot eu
Description:
------------
I've encountered this weird segfault
it seems to be a combination of 'newer' techniques that goes wrong somewhere
- iteration by reference :: demonstrated in the
Foo class
- array destruction :: at the end of the example
- output :: all the var_dump's (both the locations and amount of var_dumps's seems to
matter)
I have no clue why this goes wrong, neither does the error log provide useful information(at least
for me)
php error log ::
[Tue Jan 09 16:46:08.907851 2018] [proxy_fcgi:error] [pid 53058:tid 140258613700352] [client
192.168.198.88:55790] AH01067: Failed to read FastCGI header
[Tue Jan 09 16:46:08.907896 2018] [proxy_fcgi:error] [pid 53058:tid 140258613700352] (104)Connection
reset by peer: [client 192.168.198.88:55790] AH01075: Error dispatching request to :
sys log ::
Alert from syslog-ng Jan 9 16:46:08 remote kernel: [926537.733411] traps: php-fpm7.1[59524] general
protection ip:55a832274080 sp:7ffca575e3d0 error:0 in php-fpm7.1[55a832036000+3d0000]
I hope that I have provided enough information to be helpful :D
Test script:
---------------
<?php
class Foo implements IteratorAggregate
{
protected $items = [
'this',
'is',
'a',
'item',
];
public function &getIterator(): Generator
{
foreach($this->items as $key => &$value)
{
yield $key => $value;
}
unset($value);
}
}
class Bar
{
public function doSomething(string $these, string $are, string $some, string $parameters):
string
{
var_dump($these, $are, $some, $parameters);
return 'success';
}
}
$data = [
new Bar,
'doSomething',
new Foo,
];
foreach($data[2] as $key => &$value)
{
$value .= ' foo';
var_dump($value);
}
unset($value);
// Some other code...
[
$obj,
$method,
$arguments,
] = $data;
var_dump($arguments, $obj->$method(...$arguments));
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75786&edit=1