[Bug 1677578] [NEW] php-fcgi: max_execution_time causes memory leaks

Launchpad Bug Tracker 1677578 at bugs.launchpad.net
Mon Feb 7 23:15:23 UTC 2022


*** This bug is a security vulnerability ***

You have been subscribed to a public security bug:

I noticed that php processes do not free memory after killing scripts
that are running more than allowed by max_execution_time directive.

My setup is lighttpd with php configured as fcgi. Sample script
(requires php-imagick) that can easily hit default 30 seconds time limit
and uses a lot of memory so leaks are easy to notice:

<?php
    define('__BASE__', 'images');
    $photos = [];
    if ($album_root = opendir(__BASE__)) {
        while (false !== ($entry = readdir($album_root))) {
            if (preg_match('/\.(jpe?g|gif|png)$/i', $entry)) {
                $photos[] = $entry;
            }
        }
        closedir($album_root);
        sort($photos);
        if (!file_exists('thumbs')) {
            mkdir('thumbs');
        }
        foreach($photos as $photo) {
            $thumb = 'thumbs/'.$photo;
            if (!file_exists($thumb)) {
                $image = new \Imagick(realpath(__BASE__.'/'.$photo));
                $image->thumbnailImage(64, 48, true, false);
                $image->writeImage($thumb);
                $image->clear;
                $image = null;
            }
        }
    }
?>

Just put many big JPGs to images directory.

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: php7.0-cgi 7.0.15-0ubuntu0.16.04.4
ProcVersionSignature: Ubuntu 4.8.0-45.48~16.04.1-generic 4.8.17
Uname: Linux 4.8.0-45-generic x86_64
ApportVersion: 2.20.1-0ubuntu2.5
Architecture: amd64
Date: Thu Mar 30 14:37:16 2017
InstallationDate: Installed on 2011-04-14 (2177 days ago)
InstallationMedia: Ubuntu-Server 10.04.2 LTS "Lucid Lynx" - Release amd64 (20110211.1)
SourcePackage: php7.0
UpgradeStatus: Upgraded to xenial on 2016-07-30 (242 days ago)

** Affects: php
     Importance: Unknown
         Status: Unknown

** Affects: imagemagick (Ubuntu)
     Importance: Undecided
         Status: Incomplete

** Affects: php7.0 (Ubuntu)
     Importance: High
         Status: Invalid


** Tags: amd64 apport-bug xenial
-- 
php-fcgi: max_execution_time causes memory leaks
https://bugs.launchpad.net/bugs/1677578
You received this bug notification because you are a member of Ubuntu Foundations Bugs, which is subscribed to imagemagick in Ubuntu.



More information about the foundations-bugs mailing list