Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 752669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:48:28+00:00 2026-05-14T14:48:28+00:00

I think I may have found a bug in PHP’s crypt() function under Windows.

  • 0

I think I may have found a bug in PHP’s crypt() function under Windows.

However: I recognize that it’s probably my fault. PHP is used by millions and worked on by thousands; my code is used by tens and worked on by me. (This argument is best explained on Coding Horror.)

So I’m asking for help: show me my fault. I’ve been trying to find it for a few days now, with no luck.

The setup

I’m using a Windows server installation with Apache 2.2.14 (Win32) and PHP 5.3.2. My development box runs Windows XP Professional; the ‘production’ server (this is an intranet setup) runs Windows Storage Server 2003. The problem happens on both.

I don’t see anything in php.ini related to crypt(), but will happily answer questions about my config.

The problem

Several scripts in my PHP app occasionally hang: the page sits there on ‘waiting for localhost’ and never finishes. Each of these scripts uses crypt to hash a user’s password before storing it in the database, or, in the case of the login page, to hash the entered password before comparing it to the version stored in the database.

Since the login page is the simplest, I focused on it for testing. I repeatedly logged in, and found that it would hang maybe 4 out of 10 times.

As an experiment, I changed the login page to use the plain text password and changed my password in the database to its plain text version. The page stopped hanging.

I saw that PHP’s latest version lists this bugfix:

Fixed bug #51059 (crypt crashes when
invalid salt are [sic] given).

So I created a very simple test script, as follows, using the same salt given in an official example:

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

This page, too, will hang, if I reload it like crazy. I only see it hanging in Chrome, but regardless of browser, the effect on Apache is the same.

Effect on Apache

When these pages hang, Apache’s server-status page (which I explained here, regarding a different problem) 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 like this:

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

Is it my fault?

I’m tempted to file a bug report to PHP on this. The argument against it is, as stated above, that bugs are nearly always my fault.

However, my argument in favor of ‘it’s PHP’s fault’ is:

  1. I’m using Windows, whereas most servers use Linux (I don’t get to choose this), so the chances are greater that I’ve found an edge case
  2. There was recently a bug with crypt(), so maybe it still has issues
  3. I have made the simplest test case I can, and I still have the problem

Can anyone duplicate this? Can you suggest where I’ve gone wrong? Should I file the bug after all?

Thanks in advance for any help you may give.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:48:29+00:00Added an answer on May 14, 2026 at 2:48 pm

    The bugs 51059 (only about passing invalid inputs) or 50947 (not the same code, 5.3 has new algorithms and features implemented in php, on all platforms) are not related to this problem.

    However http://bugs.php.net/bug.php?id=51424 is. I already posted a partial patch there, but it solves most of the possible locks but it is indeed not sufficient. A full fix will be present in the next 5.3 release.

    By the way, it is not windows specific but about the threaded SAPI (windows apache 2.2 for example).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 374k
  • Answers 374k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Gotcha #1 - Changes application pool If your ASP.NET project… May 14, 2026 at 7:58 pm
  • Editorial Team
    Editorial Team added an answer You would need to write your own component if you… May 14, 2026 at 7:58 pm
  • Editorial Team
    Editorial Team added an answer This question is a specialization of a more general question… May 14, 2026 at 7:58 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.