Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

output to STDERR/warn hangs Perl under Apache at ~64,800 bytes

by RockyMtn (Novice)
on Jul 17, 2014 at 00:31 UTC ( #1093965=perlquestion: print w/replies, xml ) Need Help??
RockyMtn has asked for the wisdom of the Perl Monks concerning the following question:

We found a CGI script that called 'warn' too many times would hang the Perl process running under Apache (separate process). When you kill the process, the Apache error log then gets the first 648 calls to warn, but no more. This does not happen from the command line, nor running in the Eclipse CGI debugger (which doesn't use Apache).

The same thing happens if we merely print to STDOUT 1000 times; it hangs on 649 (based on browser stdout). 100 bytes per call * 648 = 64,800 bytes. (100 more bytes shouldn't be over 64*1024=65536 yet.)

Any ideas please?

env details:

  • Apache on windows (httpd-2.2.22-win32-x86-openssl-0.9.8t)
  • Perl v5.18.2 ( MSWin32-x86-multi-thread-64int - ActiveState)
  • Apache is running locally, writing to C:
  • You can try this with:

    #!C:\perl\bin\perl.exe use strict; select( STDERR ); $| = 1; select( STDOUT ); $| = 1; print <<HTML_HEADER; Content-type: text/plain <HTML> <head> <title></title> </head> <body style='background-color:#cccccc'> HTML_HEADER # Write to stdout lot of times... for ( my $lineNumber = 1; $lineNumber <= 1000; $lineNumber++ ) { print "$lineNumber...<br>\n"; my $errMsg = substr( "Line $lineNumber....." x 10, 0, 99) . "\n"; print STDERR $errMsg; #called 649, writes 648x successfully; + 648*100=64,800; 64*1024=65536 #warn( $errMsg); #called 649, write 648x successfully } print <<HTML_TRAILER; </body> </HTML> HTML_TRAILER
    Any help is appreciated.

    Replies are listed 'Best First'.
    Re: output to STDERR/warn hangs Perl under Apache at ~64,800 bytes
    by Anonymous Monk on Jul 17, 2014 at 03:13 UTC

      Apache cares more about runtime than how many bytes you send :) try

      STDOUT->autoflush(1); STDERR->autoflush(1);
    Re: output to STDERR/warn hangs Perl under Apache at ~64,800 bytes
    by cord-bin (Friar) on Jul 17, 2014 at 13:32 UTC
      This doesn't much has to do with perl but with Apache’s configuration. You should check more on Apache side and play with the tunings or maybe use FastCGI.
      There is also a module CGI::Inspect for debugging a running perl web application.
        Thanks for your input. Yes, this does seem to be more with Apache than Perl. For anyone else facing this issue, I found it does appear similar to a bug fixed back in Apache 2.0. where the stderr pipe fills up while Apache blocks awaiting stdout.

        It does complete fine and flush stderr IF I close STDOUT, but that's hardly a good workaround.


    Log In?

    What's my password?
    Create A New User
    Node Status?
    node history
    Node Type: perlquestion [id://1093965]
    Front-paged by toolic
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (5)
    As of 2018-06-24 07:08 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (126 votes). Check out past polls.