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 |
2.4.3 is irrelevant.
appears to work.
2.4.3 is irrelevant.
State ⇒ Resolved
2.4.3 is irrelevant.
Assigned to
State ⇒ Assigned
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.
State ⇒ Resolved
fixed by commits mentioned in this ticket (and possibly others).
[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
memory leak in horde_core-2.4.3
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
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.
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 queuingSince 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
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).
following endless loop of
this (i.e. what functions are being called repeatedly).
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
...
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.
Also there was a similar report in the mail list:
http://thread.gmane.org/gmane.comp.horde.user/30547
State ⇒ Feedback
My guess is that there is an error in your config file:
$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
Priority ⇒ 1. Low
My guess is that there is an error in your config file:
Priority ⇒ 3. High
State ⇒ Unconfirmed
Patch ⇒ No
Milestone ⇒
Summary ⇒ horde crashes with php memory exhaustion
Type ⇒ Bug
Queue ⇒ Horde Framework Packages
[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