php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56870 Memory allocation error
Submitted: 2006-03-02 03:11 UTC Modified: 2015-07-26 20:24 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: mwilmes at wilminator dot com Assigned: luckec (profile)
Status: Suspended Package: id3 (PECL)
PHP Version: 5.1.2 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mwilmes at wilminator dot com
New email:
PHP Version: OS:

 

 [2006-03-02 03:11 UTC] mwilmes at wilminator dot com
Description:
------------
A function catalogs the id3 tags of files in a directory.  Not all files are mp3 files.  The loop uses a dir() object to get the filenames.

Seems to work fine for the first few files, then this error appears:

Fatal error: Allowed memory size of 25165824 bytes exhausted (tried to allocate 1852404086 bytes) in /home/mwilmes/www/mp3play/index.php on line 13

MP3 File size: 5,812,461 bytes

Code:
$id3info = id3_get_tag($filename);

Error follows around even after the 'offending' mp3 file is removed from the directory.

Error exists even after the non-mp3 file is removed.

php.ini set to allow 24M memory for script execution
uses gd, sqlite, mysql, and id3 v. 0.2

Reproduce code:
---------------
function catalogMP3File($filename) {
    $id3info = id3_get_tag($filename);
    if ($id3info && is_numeric($id3info['genre'])) {
$id3info['genre'] = "({$id3info['genre']}) ".id3_get_genre_name($id3info['genre']);}
    return $id3info;
}
function findMP3Files($path,$recurse=false) {
    $path=realpath($path).'/';
    $mp3files=array();
    $dir=dir($path);
    while($file=$dir->read()) {
        if ($file!='.' && $file!='..') {
            $filename=$path.$file;
            if (is_dir($filename)) {
                if ($recurse) {
                    $result=findMP3Files($filename,$recurse);
                    if ($result) { $mp3files+=$result;}
                }
            }
            else {
                $id3info=catalogMP3File($filename);
                if($id3info) {$mp3files[$filename]=$id3info;
}
            }
        }
    }
    return $mp3files;
}



Expected result:
----------------
When calling findMP3Files, I should get an array of id3 tag results with the keys being the names of the files the data was collected from.

Actual result:
--------------
System attempts to allocate 1.8GB RAM and fails.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-02 22:20 UTC] mwilmes at wilminator dot com
Problem might be from mal-formed id3 tags.
 [2006-05-04 13:34 UTC] lacent at gmail dot com
heres what i'm getting. sounds like the same issue.

FATAL: emalloc(): Unable to allocate 1852404086 bytes 

this happens when i use id3_get_tag on a file that fails when i check the sfv.

the only other function i could think of off the bat in the id3 library was id3_get_version, which returns the expected version id i'm assuming, of "31" for this file, and i've seen that value in other files that work with id3_get_tag, so using id3_get_version isn't usable info in this error.

let me know via email if theres a fix.
 [2006-05-04 18:47 UTC] lacent at gmail dot com
more info. 

after getting home i gathered other group release mp3s that fail matching with the checksums in the sfvs for each release. each of these files still work with id3_get_tag(), so my comment before isn't the most exact bug pinpointing, but atleast it gives a possible direction. if you want a small mp3 that is causing the error, contact me on aim, "lacstewie" or email me.
 [2006-05-04 18:52 UTC] lacent at gmail dot com
ps: i'm using iis6, and php 5.1.2
 [2006-05-05 13:54 UTC] lacent at gmail dot com
for the time being i'm using checks to make sure i get a tag by looping threw v1.0, 1.1, 2.1 and best if i must, tho i think i'm gonna kill the best attempt, due to it possibly being a v2.2 or above, which seem to have the most problems. 

i dunno if this helps but i copyed the file and played with the tags in winamp and got it to work after changing some stuff, notable change was composer, tho that wasn't the fix all of the time.
 [2006-05-07 12:27 UTC] lacent at gmail dot com
i'm using this for now, i can't figure out what 31 is tho.

the ones that are comment out are ones that keep causing problems with my script and files. 

	// allowed id3 versions
	//$allowedid3s[]=0;	// ID3_BEST
	$allowedid3s[]=1;	// ID3_V1_0
	$allowedid3s[]=3;	// ID3_V1_1
	$allowedid3s[]=4;	// ID3_V2_1
	//$allowedid3s[]=12;	// ID3_V2_2
	//$allowedid3s[]=28;	// ID3_V2_3
	//$allowedid3s[]=60;	// ID3_V2_4
	$allowedid3s[]=31; 	// UNKNOWN?
 [2008-09-18 05:27 UTC] phlesly at gmail dot com
this might be useless as its sort of been mentioned but i was having what appears to be the same error, i noticed that it only happened with files where composer ID3v2 tags ended with a "." retagging some of the files seemed to support this theory as they now work.

don't know if this is useful information but thought i'd add it anyway.
 [2008-10-23 20:14 UTC] FFVison at yahoo dot com
I was running into a similar problem as well.  I was writing 
a script to run through all of the MP3s in my "My Music" 
folder.  It would go through them, put the filenames into an 
array, and then, run a foreach loop.  I tried to get it to 
display the artist and title of each song and show it as a 
sort of xml file (I nabbed a flash player that uses an xml 
file for the playlist, but it turns out that it can be any 
type of ascii file.  Well, this throws the same error as 
mentioned earlier after only the first file.  I have even 
manually set the array to only a few filenames and it would 
still crash after the first one.  Interestingly enough, I 
did comment out the first one and went with the second 
filename as the first member of the array and it would crash 
even before it got to it.  I have even tried using php to 
comment out the lines where it would output the tag info and 
it would still crash.  BTW, I have determined that the 
versions are basically descriptions of bits in the file, so 
a value of 31 would be a combination of having a ID3 V1.1 
tag and an ID3 V 2.3 tag.  This is also the most common 
among my MP3s which are not working.  I should see if I can 
find something in the ID3 tag itself that might clue me in.  
if anyone wants to see my code, please let me know.
 [2009-03-27 13:00 UTC] spam2 at rhsoft dot net
This happens if there are images or lyrics in the id3-tag
Images always, lyrics only if they are big enough

It would be very very nice to fix because i have at home a webapplication written to deal with my music and want automatically add all lyrics from my database with "eyeD3", but after that the indexer would crash :-(

With 'Hello' There is no problem
/usr/bin/eyeD3 --lyrics=eng::'Hello' /home/harry/Desktop/test.mp3

After setting the real lyrics id3_get_tag() crashs
/usr/bin/eyeD3 --lyrics=eng::'where are those happy days they seem so hard to find
I try to reach for you but you have closed your mind                              
whatever happened to our love                                                     
I wish I understood                                                               
it used to be so nice, it used to be so good                                      

so when you'\''re near me darling can'\''t you hear me, SOS
the love you gave me nothing else can save me, SOS         
when you'\''re gone                                        
how can I even try to go on                                
when you'\''re gone                                        
though I try how can I carry on                            

you seem so far away though you were standing near
you made me feel alive but something died I fear
I really tried to make it up
I wish I understood
what happened to our love, it used to be so good

so when you'\''re near me darling can'\''t you hear me, SOS
the love you gave me nothing else can save me, SOS
when you'\''re gone
how can I even try to go on
when you'\''re gone
though I try how can I carry on

so when you'\''re near me darling can'\''t you hear me, SOS
the love you gave me nothing else can save me, SOS
when you'\''re gone
how can I even try to go on
when you'\''re gone
though I try how can I carry on

when you'\''re gone
how can I even try to go on
when you'\''re gone
though I try how can I carry on' /home/harry/Desktop/test.mp3
 [2010-05-29 06:18 UTC] libertychisasuro at yahoo dot com
I am currently using the idea from lacent and got it to work like this:

			// allowed id3 versions
			// $allowedid3s[]=0;	// ID3_BEST
			// $allowedid3s[]=1;	// ID3_V1_0
			// $allowedid3s[]=3;	// ID3_V1_1
			// $allowedid3s[]=4;	// ID3_V2_1
			// $allowedid3s[]=12; // ID3_V2_2
			// $allowedid3s[]=28; // ID3_V2_3
			// $allowedid3s[]=60; // ID3_V2_4
			// $allowedid3s[]=31; // UNKNOWN!
		
				$index = 1;
				
					foreach($songs as $song){
						
						$version = id3_get_version($song['path']);
						
						if($version & ID3_V1_0) 
						    $tag = id3_get_tag($song['path'], ID3_V1_0);
				
						if ($version & ID3_BEST) 
						    $tag = id3_get_tag($song['path'], ID3_BEST);
							
							if($tag)
								$this->songs[$index]['file'] = $song['file'];
								$this->songs[$index]['artist'] = $tag['artist'];
								$this->songs[$index]['title'] = $tag['title'];
								$this->songs[$index]['version'] = $version;
									$index++;

					}
 [2015-07-26 20:24 UTC] cmb@php.net
-Status: Assigned +Status: Suspended
 [2015-07-26 20:24 UTC] cmb@php.net
The id3 extension is unmaintained (no release for more
than 10 years). I'm suspending this report until a new maintainer
is found.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC