Memory problems running finfo::buffer with PHP_CLI

Bug #1914401 reported by Hamid Alaei
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
file (Ubuntu)
New
Undecided
Unassigned

Bug Description

PHP internally uses libmagic for getting information about files. This sample php code consumes 483 MB of RAM for detecting mimetype of a 48 MB MP3 file using php7.4 but it uses only 56 MB with php7.2.

    $finfo = new finfo(FILEINFO_MIME_TYPE, '');
    $contents = file_get_contents('file.mp3');
    echo($finfo->buffer($contents));

The bug is reported to php as well. They say it should be reported to libmagic. See https://bugs.php.net/bug.php?id=79263

The PHP bug is over 1 year old.

ProblemType: Bug
DistroRelease: Ubuntu 18.04
Package: libmagic1 1:5.32-2ubuntu0.4
ProcVersionSignature: Ubuntu 4.15.0-135.139-generic 4.15.18
Uname: Linux 4.15.0-135-generic x86_64
NonfreeKernelModules: nvidia_modeset nvidia
ApportVersion: 2.20.9-0ubuntu7.21
Architecture: amd64
CurrentDesktop: ubuntu:GNOME
Date: Wed Feb 3 15:04:30 2021
Dependencies:
 gcc-8-base 8.4.0-1ubuntu1~18.04
 libc6 2.27-3ubuntu1.4
 libgcc1 1:8.4.0-1ubuntu1~18.04
 libmagic-mgc 1:5.32-2ubuntu0.4
 zlib1g 1:1.2.11.dfsg-0ubuntu2
InstallationDate: Installed on 2018-10-07 (849 days ago)
InstallationMedia: Ubuntu 18.04.1 LTS "Bionic Beaver" - Release amd64 (20180725)
ProcEnviron:
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: file
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Hamid Alaei (halaei) wrote :
affects: ubuntu → file (Ubuntu)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers