IPTC maintenance fails with out of memory???

cchiappa
cchiappa's picture

Joined: 2008-08-11
Posts: 99
Posted: Fri, 2012-04-27 18:05

Trying to reload all of my IPTC data to pick up some new tags, the task hung after about 5% and further attempts to restart hang at the "Starting up" phase. Suffering through enabling debugging with a local.php (and running into timezone problems even after setting it in php.ini files, etc), I seem to have the iptc.php file trying to allocate about 3.5GB of memory:

2012-04-27 13:46:07 -04:00 --- error: Kohana_PHP_Exception [ 1 ]: Allowed memory size of 134217728 bytes exhausted (tried to allocate 3864453071 bytes)
/usr/local/src/gallery3-contrib/3.0/modules/iptc/helpers/iptc.php [ 38 ]
#0 [internal function]: Kohana_PHP_Exception_Core::shutdown_handler(NULL)
#1 /av/gallery3/system/core/Event.php(208): call_user_func_array(Array, Array)
#2 /av/gallery3/system/core/Kohana.php(549): Event_Core::run('system.shutdown')
#3 [internal function]: Kohana_Core::shutdown()
#4 {main}

Line 38 seems to correspond to:

                  $iptc = iptcparse($iptcBlock);

Has anyone else seen something like this before? Would it be possible to catch and swallow this error under the assumption that I have a photo or two with a garbage IPTC block (my knowledge of PHP is very slim)? Would it be possible to at least see the file that is likely causing the problem? The lack of debuggability is somewhat frustrating...

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 26100
Posted: Fri, 2012-04-27 20:28

I have never used the module so can't really comment.
http://php.net/manual/en/function.iptcparse.php
is a build in function of php. So if you are getting a memory issue I can only suggest allocating more.

FAQ: PHP memory_limit - Why do I get the error Allowed memory size of Xxx bytes exhausted?
yes it is a G2 FAQ but should work for G3.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
cchiappa
cchiappa's picture

Joined: 2008-08-11
Posts: 99
Posted: Fri, 2012-04-27 20:32

Yah, if it was a matter of a couple of hundred megs I would just up it, but I don't think things would improve if I let it allocate 3.2GB (and this is a 32 bit system so that would probably fall over anyhow). I'll see if I can't bulletproof it a bit...

 
cchiappa
cchiappa's picture

Joined: 2008-08-11
Posts: 99
Posted: Mon, 2012-04-30 01:02

It appears to be non-trivial to catch a php out-of-memory error (a quick google implies you need to replace the normal PHP, and I assume Kohana, error handler). In any case, it turns out that the out of memory error is caused by php misparsing the IPTC header. I'm not sure what is wrong (exiftool & exiv2 both seem happy with the files) but I sent a patch to the php guys which at least fixes the bogus OOM error: http://git.php.net/?p=php-src.git;a=commitdiff;h=d44a3839861113dee10c7041d589096b82f23cc5
With that fix, my IPTC reload task seems to be chugging along fine (it's just a specific subset of files which it seems to have trouble parsing).