-
-
Notifications
You must be signed in to change notification settings - Fork 947
Removal of CONSTANT_SCALAR_UNION_THRESHOLD causing out-of-memory condition #5527
Copy link
Copy link
Closed
Description
Bug report
Hi, since 0.12.95 I have a PHP file that is causing very long run times, eventually terminating in an out-of-memory condition where previously it was super fast and used less than 1GB. This snippet will also cause a timeout in the playground.
I have narrowed it down to the below piece of a Base64 decoder, and it's the adding of the four lines at the end of the function that is causing the issue. As you delete the last lines of the function one at a time performance improves. Using all four lines causes PHPStan to run out of memory.
<?php
class Base64
{
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
public function decode()
{
$chars = array_flip(str_split(self::chars));
$buf = '';
$res = $chars[$buf[0]] << 18;
$res += $chars[$buf[1]] << 12;
$res += $chars[$buf[2]] << 6;
$res += $chars[$buf[3]];
}
}I was able to git bisect the issue down to commit phpstan/phpstan-src@c56d866
Current output is:
../phpstan-src/bin/phpstan analyse src/Helper/Base64.php --memory-limit 1G --level 1
PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 536870920 bytes) in /Users/chrisl/Code/phpstan-src/src/Analyser/MutatingScope.php on line 1106
Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 536870920 bytes) in /Users/chrisl/Code/phpstan-src/src/Analyser/MutatingScope.php on line 1106Did PHPStan help you today? Did it make you happy in any way?
PHPStan is great!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels