PDA

View Full Version : Out of memory


Wassercrats
02-08-2006, 12:11 AM
http://www.aota.net/forums/showthread.php?postid=145163#post145163I have updated Perl's CGI module from 3.05 to 3.15... See if that helpsNope, I still get the out of memory error when using the code I used, but not in the server logs. It's not stopping be from doing what I want at the moment, but if you want to track down the problem, the following code demonstrates it:
########################################################

print "Cache-Control: no-cache, must-revalidate\n";
print "Pragma: no-cache\n";

print "Content-type: text/html\n\n";

BEGIN
{
use CGI::Carp qw( fatalsToBrowser );
CGI::Carp::carpout(\*LOGGY) if open
(LOGGY, '>>'.__FILE__.'.err.log');
}

$var = 'a'x100000000;An out of memory error will appear in a file named name_of_above_file.err.log, but it won't appear in /big/dom/xexample/logs_web/error or /big/dom/xexample/logs_cgi/script.

I had this same problem (http://www.aota.net/forums/showthread.php?t=13554) almost three years ago. The code that I posted later in that thread that caused the out of memory error doesn't cause the error now. Maybe there was something else about the script, or maybe it's the new version of Perl. The code that caused it for me yesterday has to be combined with some other code from the script, so I just created the demo above using $var = 'a'x100000000;.

Terra
02-08-2006, 12:55 AM
It won't get logged, because the Linux Kernel is killing it, not Apache... All Apache sees is that the script was terminated, but it has no idea why... It does not reap the wait status code from the killed child CGI script pid, therefore there is no way to log it...

When Apache switched to using unbuffered CGI, this whole functional area (spawning CGI subprocesses) got quite complicated and I would assume in their quest to be portable across many architectures - things like this was set aside... I've looked at the code and I don't see an easy way to do it either... :(

So, bottom line, any script that exceeds the CPU runtime or the Memory limit, there is no way to convey that to the Apache logs... However, there are customizations done to the kernel that does report it to us at the server level by hooking into the kernel rlimit handling... Unfortunately, there is no way to sanitize and push that up to the clients view at this time...

--
Terra
sysAdmin
FutureQuest

Wassercrats
02-08-2006, 01:51 AM
there are customizations done to the kernel that does report it to us at the server level by hooking into the kernel rlimit handling...Good, that was the other thing I was wondering about. At least it wouldn't be a mystery to you if there's a server slowdown due to these kinds of errors.

The blank screens with no error were perplexing for a while, but luckily I remembered CGI::Carp::carpout. I guess the missing time stamp would be an issue for the module developer.