ID:               49770
 Updated by:       [email protected]
 Reported By:      wickham at affl dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Reproducible crash
 Operating System: Windows Server 2003
 PHP Version:      5.2SVN-2009-10-04 (snap)
 New Comment:

Can you try with the NTS version and FastCGI please? 


Previous Comments:
------------------------------------------------------------------------

[2009-10-04 21:57:06] wickham at affl dot com

Description:
------------
We are having an issue with deadlocking requests from php.  This is
only occuring during heavy load.  In our situation every user hits the
same php file every 30 seconds.  This php file downloads a gzip file to
the client and hands it off to a flex application.

This same code has run on 5 different servers over the last 3 years
without this issue occuring.  Two weeks ago we completed a migration to
a new server, and now we are seeing this deadlocking issue.

We originally put a ticket into Microsoft, and ran some debug.  They
attribute the issue directly to a php deadlocking issue, with some of
the data dump below.

We are running php on a Windows Server 2003 with IIS 6.  The php
settings can be found at http://games.affl.com/test.php

Reproduce code:
---------------
<?PHP
 
// Include this function on your pages
function print_gzipped_page() {

    global $HTTP_ACCEPT_ENCODING;
    if( headers_sent() ){
        $encoding = false;
    }elseif( strpos($HTTP_ACCEPT_ENCODING, 'x-gzip') !== false ){
        $encoding = 'x-gzip';
    }elseif( strpos($HTTP_ACCEPT_ENCODING,'gzip') !== false ){
        $encoding = 'gzip';
    }else{
        $encoding = false;
    }

    if( $encoding ){
        $contents = ob_get_contents();
        ob_end_clean();
        header('Content-Encoding: '.$encoding);
        print("\x1f\x8b\x08\x00\x00\x00\x00\x00");
        $size = strlen($contents);
        $contents = gzcompress($contents, 9);
        $contents = substr($contents, 0, $size);
        print($contents);
        exit();
    }else{
        ob_end_flush();
        exit();
    }
}

 function gzfile_get_contents($filename, $use_include_path = 0)
{
    //File does not exist
    if( !...@file_exists($filename) )
    {    return false;    }
  
    //Read and imploding the array to produce a one line string
   $data = gzfile($filename, $use_include_path);
   $data = implode($data);
   return $data;
}

// At the beginning of each page call these two functions
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'))
{
    ob_start("ob_gzhandler");
}
else
{
    ob_start();
}

ob_implicit_flush(0);


// $reqGzFileName =  "players.XML.GZ";
$reqGzFileName = $_POST["gzfilename"];
//Write file content here... live_scores_20071022231636.XML.GZ  
live_scoring_players.xml.GZ   
// echo gzfile_get_contents ("players.XML.GZ");
echo gzfile_get_contents($reqGzFileName);
 
// Call this function to output everything as gzipped content.
print_gzipped_page();

 
?> 

Actual result:
--------------
Here is what I found in the dumps you sent to us:

There are two threads (4 and 11) deadlocking against each other.

Thread 9 is also waiting on a critical section owned by 11.

Thread 10 is waiting on a critical section owned by 9

There are 82 additional threads waiting on the critical section owned
by thread 10.

The critical section owned by thread 4 is inside of ODBCINT.dll.  The
critical section owned by thread 4 is not located within any loaded
DLL.

There may be something in the PHP code being run or something in the
PHP ISAPI that is causing the issue.  If we can get proper symbols for
the PHP components that are laoded I can dig further in a see if we can
glean any more details.

0:000> !critlist
CritSec at  1c04ad0.  Owned by thread 11.  Deadlocked on CritSec
261fc4.
  Waiting Threads: 4 9
CritSec at 77bf3a48.  Owned by thread 10.  Blocked by Deadlock.
  Waiting Threads: 5 6 7 8 31 34 38 39 40 41 42 43 44 45 46 47 48 49 50
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
100 101 102 103 104 105 106 107 109 110 111 112 113 114 115 CritSec at 
1c04a88.  Owned by thread 9.  Blocked by Deadlock.
  Waiting Threads: 10 
CritSec at   261fc4.  Owned by thread 4.  Deadlocked on CritSec
1c04ad0.
  Waiting Threads: 11 


0:000> ~4kbn
 # ChildEBP RetAddr  Args to Child              
00 00f7d44c 7c827d29 7c83d266 0000082c 00000000
ntdll!KiFastSystemCallRet
01 00f7d450 7c83d266 0000082c 00000000 00000000
ntdll!NtWaitForSingleObject+0xc
02 00f7d48c 7c83d2b1 0000082c 00000004 00000001
ntdll!RtlpWaitOnCriticalSection+0x1a3
03 00f7d4ac 77bcb7a9 01c04ad0 00000090 00f7d4f8
ntdll!RtlEnterCriticalSection+0xa8
04 00f7d4bc 77bbf35d 0000000b 77bf4a00 00000090 msvcrt!_lock+0x30
05 00f7d4f8 77bbe1f0 77bf4a00 00000090 00000004
msvcrt!_alloc_osfhnd+0x27
06 00f7d530 77bbe303 00000004 086eba08 042a0a20 msvcrt!_creat+0x52
07 00f7d564 01fffee8 00000004 020e4770 0429fbf0 msvcrt!_dup+0x55
WARNING: Stack unwind information not available. Following frames may
be wrong.
08 00f7d580 01ffda08 00000000 0429bbb0 020e4770
php5ts!php_version_compare+0x41a8
09 00000000 00000000 00000000 00000000 00000000
php5ts!php_version_compare+0x1cc8

0:000> ~11kbn
 # ChildEBP RetAddr  Args to Child              
00 0114d45c 7c827d29 7c83d266 00000714 00000000
ntdll!KiFastSystemCallRet
01 0114d460 7c83d266 00000714 00000000 00000000
ntdll!NtWaitForSingleObject+0xc
02 0114d49c 7c83d2b1 00000714 00000002 00261fc4
ntdll!RtlpWaitOnCriticalSection+0x1a3
03 0114d4bc 77bbf3f4 00261fc4 77bf4a00 0000006c
ntdll!RtlEnterCriticalSection+0xa8
04 0114d4f8 77bbe1f0 77bf4a00 0000006c 00000003
msvcrt!_alloc_osfhnd+0xbe
05 0114d530 77bbe303 00000003 0316d680 03320f28 msvcrt!_creat+0x52
06 0114d564 01fffee8 00000003 020e4770 0331fcb8 msvcrt!_dup+0x55
WARNING: Stack unwind information not available. Following frames may
be wrong.
07 0114d580 01ffda08 00000000 0331bc78 020e4770
php5ts!php_version_compare+0x41a8
08 00000000 00000000 00000000 00000000 00000000
php5ts!php_version_compare+0x1cc8

0:000> lmvm php5ts
start    end        module name
01e20000 0231c000   php5ts   C (export symbols)       php5ts.dll
    Loaded symbol image file: php5ts.dll
    Image path: \\?\C:\PHP\php5ts.dll
    Image name: php5ts.dll
    Timestamp:        Wed Jun 17 11:16:31 2009 (4A3908CF)
    CheckSum:         00000000
    ImageSize:        004FC000
    File version:     5.2.10.10
    Product version:  5.2.10.0
    File flags:       0 (Mask 3F)
    File OS:          4 Unknown Win32
    File type:        2.0 Dll
    File date:        00000000.00000000
    Translations:     0409.04b0
    CompanyName:      The PHP Group
    ProductName:      PHP Script Interpreter
    InternalName:     php5ts.dll
    OriginalFilename: php5ts.dll
    ProductVersion:   5.2.10
    FileVersion:      5.2.10.10
    PrivateBuild:     5.2.10.10
    SpecialBuild:     5.2.10.10
    FileDescription:  PHP Script Interpreter
    LegalCopyright:   Copyright (c) 1997-2007 The PHP Group
    LegalTrademarks:  PHP
    Comments:         PHP



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=49770&edit=1

Reply via email to