php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42585 die() in event handler => PHP hangs
Submitted: 2007-09-07 09:49 UTC Modified: 2017-10-24 03:32 UTC
Votes:7
Avg. Score:2.7 ± 0.7
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: csaba at alum dot mit dot edu Assigned:
Status: Open Package: COM related
PHP Version: 5.2.4 OS: Win XP Pro
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: csaba at alum dot mit dot edu
New email:
PHP Version: OS:

 

 [2007-09-07 09:49 UTC] csaba at alum dot mit dot edu
Description:
------------
If I have a COM object call into PHP (via com_event_sink or IE's window.setTimeout) with a die() within the called code, then PHP hangs.

In the example below, IE comes up and waits around for 4 seconds, after which an $ie->quit() is issued.  In the event handler (function OnQuit()) a die() is issued.  While IE does shut down, PHP does not return me the command prompt.  This is from PHP CLI, of course.

Csaba Gabor from Vienna

Reproduce code:
---------------
<?php 
class IESink { 
  public $terminated = false; 
  public function TitleChange($text) { 
    echo("title has changed: $text \n"); }

  public function OnQuit() { 
    print "Quitting\n";
    die();
    print "Died\n";
    $this->terminated = true; 
  } } 

$ie = new COM("InternetExplorer.Application"); 
$ie->Visible = true; 
$sink = new IESink; 
com_event_sink($ie, $sink, "DWebBrowserEvents2"); 
$ie->Navigate("http://www.php.net/"); 

$start = time();
$quitted = false;

while (!$sink->terminated) { 
  com_message_pump(200); 
  if (time()-$start>4 && !$quitted) {
    $quitted=true;
    $ie->quit(); } } 
print "Finished!\n"; 
?>

Expected result:
----------------
I expect to be shown the following three lines, ie to go away, AND for PHP to terminate:
title has changed: PHP: Hypertext Preprocessor
title has changed: PHP: Hypertext Preprocessor
Quitting

Actual result:
--------------
The above 3 lines are shown, IE goes away, BUT php does not terminate.

Also, note that if I manually shut IE down, instead of waiting the 4 seconds, then I get the following additional line (and PHP still hangs the cmd prompt):
Fatal error: Call to undefined method com::quit() in Unknown on line 0

It seems to me that the while loop stays active, since that's the only place that $ie->quit() is issued.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-07 11:04 UTC] jani@php.net
Assigned to the COM maintainer.
 [2008-10-21 19:43 UTC] atomiku at gmail dot com
I seem to be experiencing this too, this is in my opinion CRITICAL.

In the class, it's supposed to die... picture something like this:

$someClass->someFunc(); //someFunc is supposed to die.
while (true) {
   echo "Test";
   sleep(5);
   die();
}

It actually makes it to the while loop, doesn't print "test" though, it just stops for 5 seconds. If I change to sleep(10), it stops for 10 seconds. No idea what is going on here.
 [2008-10-21 19:52 UTC] atomiku at gmail dot com
I'm going to take back my previous comment, turns out if you try to view the POST data in firebug of an ajax call which is hanging (while loop or whatever), it'll screw it up, mess the cookies up and do some weird stuff. Please delete this comment and my previous comment.
 [2017-10-24 03:32 UTC] kalle@php.net
-Status: Assigned +Status: Open -Assigned To: wharmby +Assigned To:
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Jan 29 14:01:24 2020 UTC