Hi All,

I have a problem that I cannot resolve. Some script, called as CGI, prints "Out of memory!" to the stderr. However, the same script does not display that error if run from the command line.

I could not isolate the problem to a simple test case; the problem does not occur for a simpler script.

The script calls another script ("worker") via open(). The other script forks and executes some "daemon" script. The problem does not occur without calling that daemon:

my $pid = fork; unless (defined($pid)) { return -1; } if ($pid != 0) { # parent return 1; } POSIX::setsid(); close(STDIN);close(STDOUT);close(STDERR); fork() && exit 0; exec("$command") or return 0;
The limits on the host are the following:
bash-3.00# ulimit -a

core file size (blocks, -c) unlimited
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 10
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 29995
virtual memory (kbytes, -v) unlimited

prstat and top displays up to 33M of memory occupied by the scripts.

When I added some trace messages, the "Out of memory!" message was written after the last command of the "worker" script.

I also tried running truss to trace the worker process. It didn't help too much:
worker: ending main
write(2, " w o r k e r : e n d i".., 19) = 19
worker ending
write(2, " w o r k e r e n d i n".., 13) = 13
setcontext(0xFFBFEAE0)
Out of memory!
write(2, " O u t o f m e m o r".., 15) = 15

Printing the text "worker ending" is the last instruction of the script:

print STDERR "worker ending"; exit 0;

Do you have any ideas, what next should I do? What could be the root of the problem? What tools could be helpful to trace it?

Thanks in advance,
pkal


In reply to Out of memory! in CGI by pkal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.