php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51666 Using crypt() makes Apache hang or crash
Submitted: 2010-04-26 17:10 UTC Modified: 2010-04-27 00:24 UTC
From: nathanmlong at gmail dot com Assigned:
Status: Not a bug Package: Reproducible crash
PHP Version: 5.3.2 OS: Win XP Pro & Storage Server 2003
Private report: No CVE-ID: None
 [2010-04-26 17:10 UTC] nathanmlong at gmail dot com
Description:
------------
Several scripts in my PHP app occasionally hang: the page sits there on 'waiting for localhost' and never finishes. I'd guess this happens 3-4 times out of 10. The common element is the usage of crypt() to hash user passwords.

The problem happens both on my development machine (Windows XP Professional) and our server (Windows Storage Server 2003). Both are running Apache 2.2.14 (Win32).

I created the simple test script below and confirmed that the problem still happens, though I have to rapidly reload the page to reproduce it.

$foo = crypt('rasmuslerdorf','r1');
echo $foo;

When these pages hang, Apache's server-status page increments the number of requests being processed and decrements the number of idle workers. The requests being processed almost all have a status of 'Sending Reply,' though sometimes for a moment they will show either 'Reading request' or 'keepalive (read).'

Eventually, Apache may crash. When it does, the Windows crash report looks something like this:

szAppName: httpd.exe
szAppVer: 2.2.14.0
szModName: php5ts.dll
szModVer: 5.3.1.0 // This report was before I upgraded to PHP 5.3.2, 
                  // but that didn't fix it
offset: 00a2615

I did not compile PHP myself; I used the zip package.

CONFIGURATION
Starting from php.ini-development, I made the following changes:

short_open_tag = On
post_max_size = 30M
include_path = "c:\path\to\my\includes\folder"
extension_dir = "C:/php/ext"
upload_max_filesize = 15M
extension=php_mysqli.dll
extension=php_pdo_mysql.dll
date.timezone = "America/New_York"
SMTP = our-server.our-domain.vwpcs.com
sendmail_from = admin@our-domain.com
sendmail_path = "C:\usr\lib\sendmail.exe"

Test script:
---------------
$foo = crypt('rasmuslerdorf','r1');
echo $foo;


Expected result:
----------------
I expect it to echo the hashed string and for the page load to complete very quickly.

Actual result:
--------------
The page frequently (maybe 3 out of 10 rapid reloads) hangs - says 'waiting for localhost' and never completes. (Tested mainly using Google Chrome.) When this happens, I can reload apache's /server-status page and see that the number of requests being processed has gone up and the number of idle workers has gone down. Eventually, Apache may crash.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-26 17:18 UTC] nathanmlong at gmail dot com
Additional note from submitter: more discussion of this problem is here:

http://stackoverflow.com/questions/2699629/did-i-find-a-bug-in-phps-crypt/2714584#2714584
 [2010-04-26 17:19 UTC] pajoye@php.net
-Status: Open +Status: Bogus
 [2010-04-26 17:19 UTC] pajoye@php.net
Duplicate of #51424
 [2010-04-26 23:16 UTC] nathanmlong at gmail dot com
@pajoye - if it's a duplicate, it adds two pieces of information:
1) This bug applies to Windows as well as Ubuntu
2) In my case, it's not necessary to call crypt() multiple times to have the bug. The scripts where I first noticed it only call crypt() once each. It was only when I began trying to isolate the problem that I made a script that just echoed the results of crypt(), then I reloaded that page rapidly.
 [2010-04-27 00:24 UTC] pajoye@php.net
It does not matter if crypt is called multiple times in the same script or from different threads. Calling it multiple times only make the dead lock easier to reproduce (or faster).

please post further comments in the other bug report so we have one single report to follow this issue.

Thanks for your feedback,
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 03:01:28 2024 UTC