-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Description
Bug report
With the below code memory usage just keeps increasing until it crashes. When third-party extensions are enabled, such as Blackfire, the memory exhausted error is replaced with a segmentation fault.
Replicable on https://phpstan.org/ - An error occured. Please try again later.
Code snippet that reproduces the problem
<?php declare(strict_types = 1);
class Widget
{
public static function getDefault()
{
$order = [0, 0];
[$column1, $column2] = [
['Foo1', 'Foo2', 'Foo3', 'Foo4'],
['Bar1', 'Bar2', 'Bar3', 'Bar4'],
];
return collect()
->map(function ($widget) use ($column1, $column2, &$order) {
if (in_array($widget->name, $column1)) {
$column = 1;
} elseif (in_array($widget->name, $column2)) {
$column = 2;
} else {
$column = count($column1) > count($column2) ? 2 : 1;
}
return [
'widget_id' => $widget->id,
'enabled' => 1,
'column' => $column, // 1-based indexing
'order' => $order[$column - 1]++ // 0-based indexing
];
})
->all();
}
}Expected output
No segmentation fault
Other info
# /home/kieran/php-src/sapi/cli/php -v
PHP 7.4.13-dev (cli) (built: Dec 30 2020 21:47:03) ( NTS DEBUG )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
# /home/kieran/php-src/sapi/cli/php -dmemory_limit=2G vendor/bin/phpstan analyse --debug -vvv
Note: Using configuration file /root/phpbug/phpstan.neon.
Result cache not used because of debug mode.
/root/phpbug/test.php
Fatal error: Allowed memory size of 2147483648 bytes exhausted at /home/kieran/php-src/Zend/zend_execute.c:185 (tried to allocate 262176 bytes) in phar:///root/phpbug/vendor/phpstan/phpstan/phpstan/src/Analyser/TypeSpecifier.php on line 244
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels