php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48809 "virtual memory exhausted: Cannot allocate memory" with libmagic/apprentice.c
Submitted: 2009-07-05 19:05 UTC Modified: 2009-07-05 22:49 UTC
Votes:49
Avg. Score:4.2 ± 1.1
Reproduced:47 of 48 (97.9%)
Same Version:15 (31.9%)
Same OS:5 (10.6%)
From: ibboard at gmail dot com Assigned:
Status: Wont fix Package: Compile Failure
PHP Version: 5.3.0 OS: CentOS 4
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-07-05 19:05 UTC] ibboard at gmail dot com
Description:
------------
I'm trying to compile PHP 5.3 on a VPS with 256MB of memory, but I keep getting "out of memory" errors before 'make' completes. I've compiled 5.2.x on the VPS before and I've freed up over 170MB of my 256MB of memory, but still I get the following error (always the same file):

virtual memory exhausted: Cannot allocate memory
make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1

My host temporarily bumped my account up to 512MB of memory, but it still took all of the free memory before failing (350MB+). Disabling the extension that the file is from with "--disable-fileinfo" gets me beyond the error and continues without running out of memory (until it hits a different error in libgd, which I'm looking in to).

May be similar to http://bugs.php.net/bug.php?id=48593, but crashes out with insufficient memory rather than hanging indefinitely.

Reproduce code:
---------------
$ wget http://uk2.php.net/get/php-5.3.0.tar.bz2/from/this/mirror
$ tar -xjvf php-5.3.0.tar.bz2
$ cd php-5.3.0
$ ./configure --prefix=/usr/local/php5-fcgi --with-kerberos=/opt --with-layout=GNU --with-regex=php --with-gettext --enable-mbstring --enable-libxml --with-pcre-regex=/opt --with-imap=shared --with-imap-ssl --with-mysql=shared,/opt --with-mysqli=shared,/usr/bin/mysql_config --with-mysql-sock=/var/lib/mysql/mysql.sock --with-libxml-dir=/opt --enable-gd-native-ttf --with-gd=/opt --with-jpeg-dir=/opt --with-freetype-dir=/opt --with-mcrypt --with-zlib-dir=/opt --with-png-dir=/opt --with-config-file-scan-dir=/usr/local/etc/php.d
$ make

Expected result:
----------------
PHP compile to complete so that I can run "sudo make install".

Actual result:
--------------
[lots of compile output]
...
/bin/sh /home/ibb_admin/temp/php-5.3.0/libtool --silent --preserve-dup-deps --mode=compile gcc -I/home/ibb_admin/temp/php-5.3.0/ext/fileinfo/libmagic -Iext/fileinfo/ -I/home/ibb_admin/temp/php-5.3.0/ext/fileinfo/ -DPHP_ATOM_INC -I/home/ibb_admin/temp/php-5.3.0/include -I/home/ibb_admin/temp/php-5.3.0/main -I/home/ibb_admin/temp/php-5.3.0 -I/home/ibb_admin/temp/php-5.3.0/ext/date/lib -I/home/ibb_admin/temp/php-5.3.0/ext/ereg/regex -I/usr/include/libxml2 -I/opt/include -I/opt/include/freetype2 -I/usr/include/imap -I/usr/kerberos/include -I/home/ibb_admin/temp/php-5.3.0/ext/mbstring/oniguruma -I/home/ibb_admin/temp/php-5.3.0/ext/mbstring/libmbfl -I/home/ibb_admin/temp/php-5.3.0/ext/mbstring/libmbfl/mbfl -I/opt/include/mysql -I/usr/include/mysql -I/home/ibb_admin/temp/php-5.3.0/ext/sqlite3/libsqlite -I/home/ibb_admin/temp/php-5.3.0/TSRM -I/home/ibb_admin/temp/php-5.3.0/Zend    -I/usr/include -g -O2  -c /home/ibb_admin/temp/php-5.3.0/ext/fileinfo/libmagic/apprentice.c -o ext/fileinfo/libmagic/apprentice.lo 
virtual memory exhausted: Cannot allocate memory
make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1


Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-05 19:08 UTC] rasmus@php.net
We know that file takes quite a bit of memory to compile on older versions of gcc.  It should be better in newer versions though.  Not much we can do about this.  We aren't going to change perfectly valid code just because some older compilers have trouble with it.
 [2009-07-05 19:24 UTC] ibboard at gmail dot com
"Quite a bit" of memory? That seems like a bit of an understatement when it will quite happily consume over 350MB of memory on a single file and previous versions of PHP could be compiled in ~150MB or less (albeit without that extension) :D

Maybe libmagic needs disabling as a default module if it was in PECL before and is known to causes problems with older compilers?

How much memory am I expected to need to compile it if it fails with 350MB? I've just watched 'top' while the compile continued and it maxed out at ~120MB without libmagic, which is far more reasonable.
 [2009-07-05 21:48 UTC] rasmus@php.net
It is probably up in the 600-700M range.  If you are using an older toolchain in a severely memory-starved environment, you shouldn't expect to be able to compile everything there.  Why not simply cross-compile from a real dev box somewhere and copy the binaries over?  You can install your production OS in a vm slice on whatever home machine you have and compile there.  
 [2009-07-05 22:46 UTC] scottmac@php.net
What version of gcc were you using?

It would be nice to track this where possible.
 [2009-07-05 22:49 UTC] scottmac@php.net
What version of gcc were you using?

It would be nice to track this where possible.
 [2010-06-21 22:32 UTC] mackeul at gmail dot com
Ran into the same problem with GCC 3.4.5 on a "2.6.9-34.EL #1 Fri Feb 24 16:44:51 EST 2006 i686 i686 i386 GNU/Linux" machine 
with 256MB of memory.
 [2010-11-16 08:52 UTC] info at fedushin dot ru
Adding --disable-fileinfo to ./configure solves the problem.
 [2013-05-27 15:01 UTC] hawkdoom at mail dot ru
Проблема особенно силно проявляется на выделенных серверах с обрезанием оперативы в тарифе, ща попробую решение предыдущего автора
 [2013-05-27 15:30 UTC] hawkdoom at mail dot ru
Ни хрена не помогло
 [2015-12-22 15:07 UTC] noreplythanks at example dot fake dot com
I had this issue too, on Raspbian (Linux) on a Raspberry Pi.
It ran out of memory, even though no other applications were using much
memory. It just displays a chunk of text to do with installing and then
does nothing (whilst the memory it is using increases to "breaking point" as shown in Task Manager), then something kicks in and kills it and it exits with an error:

"virtual memory exhausted: Cannot allocate memory
Makefile:742: recipe for target ext/fileinfo/libmagic/apprentice.lo failed
make:  *** [ext/fileinfo/libmagic/apprentice.lo] Error 1
 [2016-05-08 20:07 UTC] no-reply-thanks at fake-url dot example dot com
Like "info at fedushin dot ru" states, adding --disable-fileinfo to ./configure "solves" the problem (I don't know if it has any negative effects though).
 [2020-11-16 15:09 UTC] nsetak at gmail dot com
I had this issue too, on Raspbian (Linux) on a Raspberry Pi.
It ran out of memory, even though no other applications were using much
memory. It just displays a chunk of text to do with installing and then
does nothing (whilst the memory it is using increases to "breaking point" as shown in Task Manager), then something kicks in and kills it and it exits with an error:

"virtual memory exhausted: Cannot allocate memory
Makefile:742: recipe for target ext/fileinfo/libmagic/apprentice.lo failed
make:  *** [ext/fileinfo/libmagic/apprentice.lo] Error 1

thanks.

 
https://www.elso7ba.com
https://www.mtba5i.com
https://www.el7lwa.com
http://banatmasr.net
 [2021-01-25 18:40 UTC] m dot aelkhalek at yahoo dot com
I had this issue too, on Raspbian (Linux) on a Raspberry Pi.
It ran out of memory, even though no other applications were using much
memory. It just displays a chunk of text to do with installing and then
does nothing (whilst the memory it is using increases to "breaking point" as shown in Task Manager), then something kicks in and kills it and it exits with an error:

"virtual memory exhausted: Cannot allocate memory
Makefile:742: recipe for target ext/fileinfo/libmagic/apprentice.lo failed
make:  *** [ext/fileinfo/libmagic/apprentice.lo] Error 1

thanks.

https://www.turbo1.co/
https://www.turbo1.co/2020/09/2022-hyundai-tucson-review.html
https://www.insurancedes.com/
https://youtu.be/7GdKYENThvw
 [2021-02-03 16:47 UTC] fluo at fluocomunicacao dot com dot br
Thank you for taking the time to write to us, but this is not<br>a bug. Please double-check the documentation available at<br><a href="https://www.ctsaudepremium.com.br/" rel="nofollow">clinica de recuperação</a> and the instructions on how to report<br>a bug at <a href="https://www.ctsaudepremium.com.br/" rel="nofollow">clinica de recuperação</a>
a
 [2021-02-03 16:48 UTC] cttratamentodroga at gmail dot com
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
<a href="https://www.fluocomunicacao.com.br/">agencia de marketing digital</a>and the instructions on how to report
a bug at <a href="https://www.fluocomunicacao.com.br/">agencia de marketing digital</a>
This is the correct behaviour.
 [2021-02-03 16:50 UTC] cttratamentodroga at gmail dot com
Thank you for taking the time to write to us, but this is not<br>a bug. Please double-check the documentation available at<br><a href="https://www.ctsaudepremium.com.br/" rel="nofollow">clinica de recuperação</a> and the instructions on how to report<br>a bug at <a href="https://www.ctsaudepremium.com.br/" rel="nofollow">clinica de recuperação</a>
a
 [2021-02-03 16:50 UTC] cttratamentodroga at gmail dot com
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
<a href="https://www.fluocomunicacao.com.br/">agencia de marketing digital</a>and the instructions on how to report
a bug at <a href="https://www.fluocomunicacao.com.br/">agencia de marketing digital</a>
This is the correct behaviour.
 [2021-03-06 15:29 UTC] vcd50802 at zwoho dot com
"Quite a bit" of memory? That seems like a bit of an understatement when it will quite happily consume over 350MB of memory on a single file and previous versions of PHP could be compiled in ~150MB or less (albeit without that extension) :D

Maybe libmagic needs disabling as a default module if it was in PECL before and is known to causes problems with older compilers?

How much memory am I expected to need to compile it if it fails with 350MB? I've just watched 'top' while the compile continued and it maxed out at ~120MB without libmagic, which is far more reasonable.


http://images.google.pt/url?sa=t&url=https://www.news000k.com/2020/05/Elantra.html


http://images.google.pt/url?sa=t&url=https://www.news000k.com/2020/05/Maserati.html

http://images.google.pt/url?sa=t&url=https://www.news000k.com/2020/05/Golf.html

http://images.google.pt/url?sa=t&url=https://www.news000k.com/2020/06/BMW.html
 [2021-03-12 02:45 UTC] seocontentmachine11 at gmail dot com
The following pull request has been associated:

Patch Name: Update Swoole ini
On GitHub:  https://github.com/php/doc-en/pull/486
Patch:      https://github.com/php/doc-en/pull/486.patch
 [2021-03-13 00:35 UTC] erbert1983 at gmail dot com
http://www.popbopshopblog.com/2009/08/summer-concert-john-legend
http://www.popbopshopblog.com/2009/08/shop-tea-two-tea-you
http://www.popbopshopblog.com/2009/08/dining-out-barking-crab
http://www.popbopshopblog.com/2009/08/rental-review-what-doesnt-kill-you
http://www.popbopshopblog.com/2009/08/shop-breathtaking-bridal
https://theq.qcc.edu/ICS/Campus_Life/Campus_Groups/Music_Club/Discussion.jnz?portlet=Forums&screen=PostView&screenType=change&id=dade1a24-c0e0-4180-91a7-0ac881f76f7f&p=2
https://my.quincy.edu/ICS/Campus_Life/Campus_Groups/Chalk_Hawks/Discussion.jnz?portlet=Forums&screen=PostView&screenType=change&id=325e610c-cfbc-470c-85a4-d3fc8642f506
https://theq.qcc.edu/ICS/Campus_Life/Campus_Groups/Music_Club/Discussion.jnz?portlet=Forums&screen=PostView&id=86354319-b241-4b48-82a6-8dfe21aa3b73
https://my.quincy.edu/ICS/Campus_Life/Campus_Groups/Chalk_Hawks/Discussion.jnz?portlet=Forums&screen=PostView&screenType=change&id=3b24bd44-3797-4376-b2d6-5d716749adbb
https://my.quincy.edu/ICS/Campus_Life/Campus_Groups/Chalk_Hawks/Discussion.jnz?portlet=Forums&screen=PostView&screenType=change&id=21808b9a-c237-4ead-b586-e8df9c5c7222
https://my.quincy.edu/ICS/Campus_Life/Campus_Groups/Chalk_Hawks/Discussion.jnz?portlet=Forums&screen=PostView&screenType=change&id=68572178-efd4-449d-a312-163a4744d5af
https://my.quincy.edu/ICS/Campus_Life/Campus_Groups/Chalk_Hawks/Discussion.jnz?portlet=Forums&screen=PostView&screenType=change&id=0748d573-c34e-481c-b324-ce1b5985ef98
 [2021-04-09 23:21 UTC] erbert1983 at gmail dot com
He also played music from his second and third: https://abre.ai/encurtador-de-link
 [2021-05-08 00:58 UTC] lavabet88 at gmail dot com
lavabet88 เป็นเว็บคาสิโน เป็นผู้ให้บริการทางด้านเกมคาสิโนออนไลน์ บาคาร่า และ <a href="http://www.lavabet88.com/">บาคาร่าออนไลน์</a> แบบเรียลไทม์ที่เชื่อถือได้ ด้วยระบบเกมที่มีมาตรฐาน ทำให้ lavabet88 เป็นเว็บที่จะช่วยให้ผู้เล่นได้รับประสบการณ์จากเกมบาคาร่าได้มากขึ้น นอกจากนี้แล้วเว็บ lavabet88 ของเรายังมีโปรโมชั่นเกมบาคาร่าที่จะช่วยให้ผู้เล่นได้รับบาคาร่า เครดิตฟรี เพื่อนำไปเล่นเกม
ดังนั้นถ้าคุณสนใจและต้องการเข้ามาสมัครเล่นเกมบาคาร่า เลือก lavabet88 เว็บเกมบาคาร่าออนไลน์ที่จะช่วยให้ผู้เล่นมีโอกาสในการทำเงินได้มากขึ้นกว่าเดิม และง่ายกว่าเดิม หากคุณอยากทดลองเล่นเกมบาคาร่าเพียงแอดไลน์แล้วเริ่มต้นเล่นเกมบาคาร่ากับเราได้เลย @lavabet88
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat May 08 08:01:24 2021 UTC