The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP suddenly stops before it's done

Discussion in 'General Discussion' started by elleryjh, May 26, 2010.

  1. elleryjh

    elleryjh Well-Known Member

    Joined:
    Apr 12, 2003
    Messages:
    479
    Likes Received:
    0
    Trophy Points:
    16
    Running PHP 5.3.2 (cli) (built: Apr 30 2010 07:29:33)
    Using suPHP.
    REDHAT Enterprise 5.5 i686 standard

    I have a particular PHP script (uses the Smarty template engine) which has a problem: after running a bunch of PHP code, it dies without warning. Putting trace echos in the code seems to fix the problem by holding off the exiting, however.

    If nothing is output before the death occurs, it gives a premature end of script headers / 500 Internal Server Error.

    For example:

    Code:
    doSomething1();
    doSomething2();
    doSomething3();  // quits here!
    doSomething4();
    doSomething5();
    

    Code:
    doSomething1();
    echo " 1 ";
    doSomething2();
    echo " 2 ";
    doSomething3();
    doSomething4();// quits here!
    doSomething5();
    
    Code:
    doSomething1();
    echo " 1 ";
    doSomething2();
    echo " 2 ";
    doSomething3();
    echo " 3 ";
    doSomething4();
    echo " 4 ";
    doSomething5();// quits here!
    
    So, I am able to fix the problem by adding "echo ' n ';" every 50 lines or so. But if I do not, it stops in the middle of output.

    So it's as if PHP exits if nothing's been output for x clock cycles.

    I have tried to modify PHP's max execution time (set_time_limit), memory limit, all with no effect.

    There is no error output by PHP when it dies (even using E_ALL).

    Seems to be limited to this one script, though much longer than most (903LOC).

    It doesn't seem to be segfaulting, as there is no core file generated.
     
  2. elleryjh

    elleryjh Well-Known Member

    Joined:
    Apr 12, 2003
    Messages:
    479
    Likes Received:
    0
    Trophy Points:
    16
    Solved? I was able to stop the problem by turning on output buffering. Still not an explanation for what is happening, but at least it's a workaround.
     
Loading...

Share This Page