I'm having an issue I can't quite figure out with php and fastcgi. I have a need to run a process in the background, but I'd like to grab the PID so I can monitor its progress and report to the user when it's finished via an AJAX request.

My only issue is that FastCGI seems to crash when I launch a process with the WshShell->Exec method, but not when I use the WshShell->Run method. It actually works fine, returns the correct pid, and runs the process in the background...but once script execution is done, the fastcgi worker process crashes. If I refresh the page several times and fastcgi hits its limit on child processes, I get a 500 internal error stating that the worker process crashed, until a new worker process is spawned a second later.

The following also shows up in the error log when the worker process crashes:Faulting application php-cgi.exe, version 5.3.6.0, faulting module unknown, version 0.0.0.0, fault address 0x572529b0.

Any idea why Exec would crash the process but Run wouldn't?

Works:

<?
	$WshShell = new COM("WScript.Shell");
	$oExec = $WshShell->Run("ping 127.0.0.1",0,false);
?>

Crashes:

<?
	$WshShell = new COM("WScript.Shell");
	$oExec = $WshShell->Exec("ping 127.0.0.1");
?>

    If you can write PHP code that causes the PHP binary to fault, I would say you might want to consider filing a bug report.

      I was unable to reproduce the crash on PHP 5.3.10 via the CLI.

      My PHP version:

      C:\php>php -v
      PHP 5.3.10 (cli) (built: Feb  2 2012 20:27:51)
      Copyright (c) 1997-2012 The PHP Group
      Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

      My test code:

      <?php
      	$WshShell = new COM("WScript.Shell");
      	$oExec = $WshShell->Exec("ping 127.0.0.1");
      	var_dump($oExec->status);
      ?>

      The output:

      int(0)

        Interesting...

        <?php 
            $WshShell = new COM("WScript.Shell"); 
            $oExec = $WshShell->Exec("ping 127.0.0.1"); 
            var_dump($oExec->status); 
        ?>

        Outputs int(0)

        However

        <?php 
            $WshShell = new COM("WScript.Shell"); 
            $oExec = $WshShell->Exec("ping 127.0.0.1"); 
            var_dump($oExec); 
        ?>

        Crashes Apache HTTP... So maybe its possible you are trying to use the variable $oExec improperly?

          I can replicate this (PHP 5.4.0 TS/ Apache 2.2.21; VC9 builds).

          The crash definitely happens at the var_dump() stage, and it doesn't really seem to matter what the scripting host did (other commands can be substituted for the ping).

          I agree: file this as a bug.

            Can either of you two replicate the same crash via the CLI? I'm getting:

            object(variant)#2 (0) {
            }

            now on PHP 5.3.3 CLI and (Apache/2.2.14 (Win32) PHP/5.3.3, MSVC6 build). I'll try matching Weedpacket's installation in a bit.

              I can get that via CLI
              Apache 2.2.21 PHP 5.3.9 VC9 x64

              But I still get a crash from Apache HTTP Server when accessing via browser.

              Edit: For completeness this is all my script contains:

              <?php
              	$WshShell = new COM("WScript.Shell");
              	$oExec = $WshShell->Exec("ping 127.0.0.1");
                 var_dump($oExec);
              ?>
                8 days later

                Sorry guys/girls, I started working on something else and sortof forgot about this for a bit.

                It's always worked via CLI for me, which is why I was thinking it had something to do with fastcgi. When you're getting crashes from apache, do you have it configured for CGI/fastCGI? I was using IIS 6.

                I didn't see IIS actually crash, it was the fastcgi process that hung, and IIS would start a new one (...maybe that's what you're seeing at the var_dump stage?)

                I find it odd that it worked fine via CLI but through IIS/fastcgi, when it crashed, it showed up in the event log as php-cgi.exe...if it WERE a php issue, I'd think it would crash via CLI too, if it were fastcgi or IIS I'd think it would show the binary for those in the event log instead.

                  Write a Reply...