6.0.0-beta1
7/16/25

[#12124] horde crashes with php memory exhaustion
Summary horde crashes with php memory exhaustion
Queue Horde Framework Packages
Queue Version Git master
Type Bug
State Resolved
Priority 1. Low
Owners Horde Developers (at) , slusarz (at) horde (dot) org
Requester Klaus.Steinberger (at) physik (dot) uni-muenchen (dot) de
Created 03/16/2013 (4505 days ago)
Due
Updated 06/07/2013 (4422 days ago)
Assigned 06/07/2013 (4422 days ago)
Resolved 06/07/2013 (4422 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch No

History
06/07/2013 08:27:34 PM dpa-bugs (at) aegee (dot) org Comment #17 Reply to this comment
nm.  Changes to fix occurred in Horde_Core 2.5.0, so report against
2.4.3 is irrelevant.
My report was against Horde_Core-2.5.0 : the problem is presented in 2.5.0.
No, I was probably using some old,  cached files.  Now everything 
appears to work.
06/07/2013 08:24:13 PM dpa-bugs (at) aegee (dot) org Comment #16 Reply to this comment
nm.  Changes to fix occurred in Horde_Core 2.5.0, so report against 
2.4.3 is irrelevant.
My report was against Horde_Core-2.5.0 : the problem is presented in 2.5.0.
06/07/2013 07:58:10 PM Michael Slusarz Comment #15
State ⇒ Resolved
Reply to this comment
nm.  Changes to fix occurred in Horde_Core 2.5.0, so report against 
2.4.3 is irrelevant.
06/07/2013 07:47:49 PM Michael Slusarz Assigned to Michael Slusarz
Assigned to Horde DevelopersHorde Developers
State ⇒ Assigned
 
06/07/2013 07:26:57 PM dpa-bugs (at) aegee (dot) org Comment #14 Reply to this comment
I can confirm, that the issue appeared with the upgrade from Horde 
Core 2.4.1 to Horde Core 2.4.3 and still exists in the newest releases.

On my system, Registry.php, function importConfig() calls
   $config = Horde::loadConfiguration('conf.php', 'conf', $app);
which in turns calls Horde.php, ::loadConfiguration().  Around line 
350 in the file, there is a loop

while (list($file, $log_check) = each($filelist))

This loop is executed around 1550 times, never terminates and leads to 
exhausting the memory.  At the beginning of the loop I inserted

   echo "file = $file, log_check=$log_check, filelist=";
   print_r ($filelist);
   echo "</br>";

this prints then 1550 times
   file = /mnt/new/home/htdocs/webmail/lib/../config/conf.php, 
log_check=1, filelist=Array ( 
[/mnt/new/home/htdocs/webmail/lib/../config/conf.php] => 1 )

The snipped modifying $filelist

                 if (!empty($conf['vhosts'])) {
                     $file = $config_dir . 'conf-' . 
$conf['server']['name'] . '.php';
                     if (file_exists($file)) {
                         $filelist[$file] = 0;
                     }
                 }

is never executed (I have no vhosts), so filelist is not changed.

The preceeding condition
   if (!$vhost_added && $app == 'horde' && $config_file == 'conf.php')

is matched only on the first iteration of the while loop.

Any ideas why doesn't the loop terminate

I have php 5.3.23 run in php-fpm with xcache.
05/30/2013 11:07:17 PM Michael Slusarz Comment #13
State ⇒ Resolved
Reply to this comment
Nobody has reported this issue in months, so a good bet it has been 
fixed by commits mentioned in this ticket (and possibly others).
04/04/2013 03:07:48 PM ronald (at) rmacd (dot) com Comment #12 Reply to this comment
I think I am hitting the same issue and can reproduce.
with horde_core-2.4.3 we got php exhaustion errors:

[Sat Mar 16 18:37:38 2013] [error] [client 85.181.133.252] PHP Fatal 
error:  Allowed memory size of 268435456 bytes exhausted (tried to 
allocate 1048576 bytes) in /usr/share/pear/Horde/ErrorHandler.php on 
line 168
...
bumping php memory to 512 M did not help, so there is probably a 
memory leak in horde_core-2.4.3
On my system:

Apr  4 16:02:51 mail php-cgi: PHP Fatal error:  Allowed memory size of 
134217728 bytes exhausted (tried to allocate 122880 bytes) in 
/srv/www/horde/config/conf.php on line 67
Apr  4 16:02:51 mail php-cgi: PHP Stack trace:
Apr  4 16:02:51 mail php-cgi: PHP   1. {main}() /srv/www/horde/index.php:0
Apr  4 16:02:51 mail php-cgi: PHP   2. Horde_Registry::appInit() 
/srv/www/horde/index.php:79
Apr  4 16:02:51 mail php-cgi: PHP   3. Horde_Registry->__construct() 
/usr/share/php/Horde/Registry.php:246
Apr  4 16:02:51 mail php-cgi: PHP   4. Horde_Registry->importConfig() 
/usr/share/php/Horde/Registry.php:426
Apr  4 16:02:51 mail php-cgi: PHP   5. Horde::loadConfiguration() 
/usr/share/php/Horde/Registry.php:1683

Like before, I checked conf.php and no errors around line 67.

Having bumped memory to 512M, same again:

Apr  4 16:05:50 mail php-cgi: PHP Fatal error:  Allowed memory size of 
536870912 bytes exhausted (tried to allocate 122880 bytes) in 
/srv/www/horde/config/conf.php on line 67
Apr  4 16:05:50 mail php-cgi: PHP Stack trace:
Apr  4 16:05:50 mail php-cgi: PHP   1. {main}() /srv/www/horde/index.php:0
Apr  4 16:05:50 mail php-cgi: PHP   2. Horde_Registry::appInit() 
/srv/www/horde/index.php:20
Apr  4 16:05:50 mail php-cgi: PHP   3. Horde_Registry->__construct() 
/usr/share/php/Horde/Registry.php:246
Apr  4 16:05:50 mail php-cgi: PHP   4. Horde_Registry->importConfig() 
/usr/share/php/Horde/Registry.php:426
Apr  4 16:05:50 mail php-cgi: PHP   5. Horde::loadConfiguration() 
/usr/share/php/Horde/Registry.php:1683

Anything else I could check?

R
03/25/2013 01:17:19 AM Michael Slusarz Comment #11 Reply to this comment
Maybe this will help.  It is possible that queued log objects have 
incorrect backtrace values if run from the queue.  This should only 
affect output, but maybe it causes certain PHP versions to crash.

Or maybe there is some issue where the log formatting is erroring and, 
since it is part of the actual log process, it is causing issues.  By 
separating the formatting from the actual storage, maybe this can be 
prevented.
03/25/2013 01:07:18 AM Git Commit Comment #10 Reply to this comment
Changes have been made in Git (master):

commit 9d126efcebf80f29a63f3ac001043361c532fc4d
Author: Michael M Slusarz <slusarz@horde.org>
Date:   Sun Mar 24 16:29:18 2013 -0600

     Bug #12124: Log details must be determined before queuing

     Since we are dealing with things like backtraces, this needs to be
     handled at the time the log request is made.

     As part of this, remove locale/TZ code from formatting code since it has
     no effect on the output (date() is both locale and TZ independent).

  framework/Core/lib/Horde.php                     |   19 +-
  framework/Core/lib/Horde/Core/Factory/Logger.php |    6 +-
  framework/Core/lib/Horde/Core/Log/Logger.php     |  175 ++++-----------
  framework/Core/lib/Horde/Core/Log/Object.php     |  265 
++++++++++++++++++++++
  framework/Core/package.xml                       |    8 +-
  5 files changed, 323 insertions(+), 150 deletions(-)

http://git.horde.org/horde-git/-/commit/9d126efcebf80f29a63f3ac001043361c532fc4d
03/21/2013 09:31:29 PM Michael Slusarz Comment #9 Reply to this comment
I guess maybe try changing Horde_Registry#importConfig() from:

             try {
                 $config = Horde::loadConfiguration('conf.php', 'conf', $app);
             } catch (Horde_Exception $e) {
                 $config = null;
             }

to:

             $config = Horde::loadConfiguration('conf.php', 'conf', $app);

in other words - we should fatally error if we can't read a 
configuration file (which absolutely shouldn't happen).

03/21/2013 09:00:50 PM Michael Slusarz Comment #8 Reply to this comment
Calling "strace horde-alarms" gives me after some initial output the 
following endless loop of
straces() are worthless.  We need the PHP code path that is causing 
this (i.e. what functions are being called repeatedly).
03/21/2013 08:39:58 AM torben (at) dannhauer (dot) info Comment #7 Reply to this comment
Hi,

I have the same problem.

starting horde-alarms results on a memory exhaust after some minutes. 
I played yesterday a bit with debug messagtes, the ptroblem seems to 
be part of "app init". I'll have to investigate that further a bit.

Calling "strace horde-alarms" gives me after some initial output the 
following endless loop of 
"open("/usr/share/php/www/horde/config/conf.php", O_RDONLY) = 3":

...
access("/usr/share/php/www/horde/lib/Core/Factory/Logger.php", F_OK) =
-1 ENOENT (No such file or directory)
access("/usr/share/php/www/horde/lib/Horde/Core/Factory/Logger.php",
F_OK) = -1 ENOENT (No such file or directory)
access("/usr/share/php/Horde/Core/Factory/Logger.php", F_OK) = 0
time(NULL)                              = 1363815000
lstat("/usr/share/php/Horde/Core/Factory/Logger.php",
{st_mode=S_IFREG|0644, st_size=4395, ...}) = 0
lstat("/usr/share/php/Horde/Core/Factory", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
lstat("/usr/share/php/Horde/Core", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
open("/usr/share/php/Horde/Core/Factory/Logger.php", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=4395, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=4395, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=4395, ...}) = 0
mmap(NULL, 4395, PROT_READ, MAP_SHARED, 3, 0) = 0x7f9e05ad0000
munmap(0x7f9e05ad0000, 4395)            = 0
close(3)                                = 0
access("/usr/share/php/www/horde/lib/Core/Factory/Injector.php", F_OK)
= -1 ENOENT (No such file or directory)
access("/usr/share/php/www/horde/lib/Horde/Core/Factory/Injector.php",
F_OK) = -1 ENOENT (No such file or directory)
access("/usr/share/php/Horde/Core/Factory/Injector.php", F_OK) = 0
time(NULL)                              = 1363815000
lstat("/usr/share/php/Horde/Core/Factory/Injector.php",
{st_mode=S_IFREG|0644, st_size=1042, ...}) = 0
open("/usr/share/php/Horde/Core/Factory/Injector.php", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1042, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=1042, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=1042, ...}) = 0
mmap(NULL, 1042, PROT_READ, MAP_SHARED, 3, 0) = 0x7f9e05ad1000
munmap(0x7f9e05ad1000, 1042)            = 0
close(3)                                = 0
access("/usr/share/php/www/horde/lib/Core/Factory/Base.php", F_OK) =
-1 ENOENT (No such file or directory)
access("/usr/share/php/www/horde/lib/Horde/Core/Factory/Base.php",
F_OK) = -1 ENOENT (No such file or directory)
access("/usr/share/php/Horde/Core/Factory/Base.php", F_OK) = 0
time(NULL)                              = 1363815000
lstat("/usr/share/php/Horde/Core/Factory/Base.php",
{st_mode=S_IFREG|0644, st_size=1810, ...}) = 0
open("/usr/share/php/Horde/Core/Factory/Base.php", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1810, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=1810, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=1810, ...}) = 0
mmap(NULL, 1810, PROT_READ, MAP_SHARED, 3, 0) = 0x7f9e05ad1000
munmap(0x7f9e05ad1000, 1810)            = 0
close(3)                                = 0
time(NULL)                              = 1363815000
open("/usr/share/php/www/horde/config/conf.php", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=7886, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=7886, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=7886, ...}) = 0
mmap(NULL, 7886, PROT_READ, MAP_SHARED, 3, 0) = 0x7f9e05ad0000
brk(0x1af1000)                          = 0x1af1000
munmap(0x7f9e05ad0000, 7886)            = 0
close(3)                                = 0
open("/usr/share/php/www/horde/config/conf.php", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=7886, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=7886, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=7886, ...}) = 0
mmap(NULL, 7886, PROT_READ, MAP_SHARED, 3, 0) = 0x7f3160a72000
brk(0xdd34000)                          = 0xdd34000
munmap(0x7f3160a72000, 7886)            = 0
close(3)                                = 0
time(NULL)                              = 1363814079
open("/usr/share/php/www/horde/config/conf.php", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=7886, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=7886, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=7886, ...}) = 0
mmap(NULL, 7886, PROT_READ, MAP_SHARED, 3, 0) = 0x7f3160a72000
munmap(0x7f3160a72000, 7886)            = 0
close(3)                                = 0
time(NULL)                              = 1363814079
open("/usr/share/php/www/horde/config/conf.php", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=7886, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=7886, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=7886, ...}) = 0
mmap(NULL, 7886, PROT_READ, MAP_SHARED, 3, 0) = 0x7f3160a72000
brk(0xdd74000)                          = 0xdd74000
munmap(0x7f3160a72000, 7886)            = 0
close(3)                                = 0
time(NULL)                              = 1363814079
open("/usr/share/php/www/horde/config/conf.php", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=7886, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=7886, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=7886, ...}) = 0
mmap(NULL, 7886, PROT_READ, MAP_SHARED, 3, 0) = 0x7f3160a72000
munmap(0x7f3160a72000, 7886)            = 0
close(3)                                = 0
time(NULL)                              = 1363814079
open("/usr/share/php/www/horde/config/conf.php", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=7886, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=7886, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=7886, ...}) = 0
mmap(NULL, 7886, PROT_READ, MAP_SHARED, 3, 0) = 0x7f3160a72000
brk(0xddb4000)                          = 0xddb4000
munmap(0x7f3160a72000, 7886)            = 0
close(3)                                = 0
time(NULL)                              = 1363814079
open("/usr/share/php/www/horde/config/conf.php", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=7886, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=7886, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=7886, ...}) = 0
mmap(NULL, 7886, PROT_READ, MAP_SHARED, 3, 0) = 0x7f3160a72000

...

03/20/2013 10:54:58 PM Michael Slusarz Comment #6 Reply to this comment
You really need to go through and find the exact spot where the memory 
is exhausting.  It *looks* like it may have something to do with the 
logging rewrite.  Except that none of the devs can reproduce.  We've 
already had one issue relating to this, and it turned out to be broken 
PHP behavior.

The best thing to do is to go to the script that is causing the 
problem, pick a random place in the script, and insert an 'print 
"HERE"; exit;' command.  If no memory exhaustion is found (i.e. you 
see HERE output and no PHP error), delete that command, move down the 
file, insert another 'print "HERE"; exit;' command, and check for 
memory exhaustion.  Once you hit a spot where the PHP script exits 
with an exhaustion error (you should not see HERE on the browser 
screen), move the command up in the file until you find the spot that 
"HERE" is shown again.  This will help to determine where the 
exhaustion (most likely an infinite loop) is occuring.
03/19/2013 01:54:47 PM Klaus (dot) Steinberger (at) physik (dot) uni-muenchen (dot) de Comment #5 Reply to this comment
Any idea, how I can debug the problem?

Also there was a similar report in the mail list:
http://thread.gmane.org/gmane.comp.horde.user/30547
03/19/2013 01:51:11 PM Michael Rubinsky Comment #4
State ⇒ Feedback
Reply to this comment
Cannot reproduce either.
03/17/2013 09:11:53 AM Klaus (dot) Steinberger (at) physik (dot) uni-muenchen (dot) de Comment #3 Reply to this comment
Can't reproduce.

My guess is that there is an error in your config file:
in /var/www/html/horde/config/conf.php on line 31
Line 31 is just this:

$conf['sql']['charset'] = 'utf-8';

the lines around:

$conf['sql']['socket'] = '/var/lib/mysql/mysql.sock';
$conf['sql']['protocol'] = 'unix';
$conf['sql']['database'] = 'horde4';
$conf['sql']['charset'] = 'utf-8';
$conf['sql']['ssl'] = false;
$conf['sql']['splitread'] = false;
$conf['sql']['phptype'] = 'mysql';


I don't see what could be the culprit.

Sincerly,
Klaus

03/17/2013 01:33:48 AM Michael Slusarz Comment #2
Priority ⇒ 1. Low
Reply to this comment
Can't reproduce.

My guess is that there is an error in your config file:
in /var/www/html/horde/config/conf.php on line 31
03/16/2013 05:54:20 PM Klaus (dot) Steinberger (at) physik (dot) uni-muenchen (dot) de Comment #1
Priority ⇒ 3. High
State ⇒ Unconfirmed
Patch ⇒ No
Milestone ⇒
Summary ⇒ horde crashes with php memory exhaustion
Type ⇒ Bug
Queue ⇒ Horde Framework Packages
Reply to this comment
with horde_core-2.4.3 we got php exhaustion errors:

[Sat Mar 16 18:37:38 2013] [error] [client 85.181.133.252] PHP Fatal 
error:  Allowed memory size of 268435456 bytes exhausted (tried to 
allocate 1048576 bytes) in /usr/share/pear/Horde/ErrorHandler.php on 
line 168
[Sat Mar 16 18:37:40 2013] [error] [client 85.181.133.252] PHP Fatal 
error:  Allowed memory size of 268435456 bytes exhausted (tried to 
allocate 1048576 bytes) in /usr/share/pear/Horde/ErrorHandler.php on 
line 168
[Sat Mar 16 18:37:46 2013] [error] [client 10.153.139.85] PHP Fatal 
error:  Allowed memory size of 268435456 bytes exhausted (tried to 
allocate 1048576 bytes) in /usr/share/pear/Horde/ErrorHandler.php on 
line 168
[Sat Mar 16 18:38:03 2013] [error] [client 188.98.223.161] PHP Fatal 
error:  Allowed memory size of 268435456 bytes exhausted (tried to 
allocate 76 bytes) in /usr/share/pear/Horde/ErrorHandler.php on line 
168, referer: 
https://webmail.physik.uni-muenchen.de/horde/imp/dynamic.php?page=mailbox
[Sat Mar 16 18:38:11 2013] [error] [client 10.153.139.85] PHP Fatal 
error:  Allowed memory size of 268435456 bytes exhausted (tried to 
allocate 1048576 bytes) in /usr/share/pear/Horde/ErrorHandler.php on 
line 168
[Sat Mar 16 18:38:20 2013] [error] [client 
2001:4ca0:4103:9:c8f6:f3d8:fb59:36cb] PHP Fatal error:  Allowed memory 
size of 268435456 bytes exhausted (tried to allocate 6 bytes) in 
/var/www/html/horde/config/conf.php on line 31

bumping php memory to 512 M did not help, so there is probably a 
memory leak in horde_core-2.4.3

We had to revert to horde_core-2.4.1 to get horde working again

Saved Queries