4

I am trying to track down the cause of my Apache PHP crashes. I am hoping there is some kind of setting, tool or something to help track down what code, configuration or what the issue is that is causing these php crashes.

In my Windows event log I have (shows apache crashing, but caused by php):

Faulting application httpd.exe, version 2.2.21.0, time stamp 0x4e6b3136, faulting module php5ts.dll, version 5.3.8.0, time stamp 0x4e537a04, exception code 0xc0000005, fault offset 0x0000c7d7, process id 0xbf4, application start time 0x01cd45afc42f0b7d.

The application utilizes Apache, PHP and MySQL on a Windows Server 2008 machine (xampp).

This is the crash in my Apache log:

[Fri Jun 08 15:56:34 2012] [notice] Parent: child process exited with status 3221225477 -- Restarting.
[Fri Jun 08 15:56:35 2012] [notice] Digest: generating secret for digest authentication ...
[Fri Jun 08 15:56:35 2012] [notice] Digest: done
[Fri Jun 08 15:56:35 2012] [notice] Apache/2.2.21 (Win32) PHP/5.3.8 configured -- resuming normal operations
[Fri Jun 08 15:56:35 2012] [notice] Server built: Sep 10 2011 11:34:11
[Fri Jun 08 15:56:35 2012] [notice] Parent: Created child process 1220
[Fri Jun 08 15:56:35 2012] [notice] Digest: generating secret for digest authentication ...
[Fri Jun 08 15:56:35 2012] [notice] Digest: done
[Fri Jun 08 15:56:35 2012] [notice] Child 1220: Child process is running
[Fri Jun 08 15:56:35 2012] [notice] Child 1220: Acquired the start mutex.
[Fri Jun 08 15:56:35 2012] [notice] Child 1220: Starting 150 worker threads.
[Fri Jun 08 15:56:35 2012] [notice] Child 1220: Starting thread to listen on port 80.
[Fri Jun 08 15:56:35 2012] [notice] Child 1220: Starting thread to listen on port 80.
[Fri Jun 08 15:57:37 2012] [notice] Parent: child process exited with status 3221225477 -- Restarting.
[Fri Jun 08 15:57:37 2012] [notice] Digest: generating secret for digest authentication ...
[Fri Jun 08 15:57:37 2012] [notice] Digest: done
[Fri Jun 08 15:57:37 2012] [notice] Apache/2.2.21 (Win32) PHP/5.3.8 configured -- resuming normal operations
[Fri Jun 08 15:57:37 2012] [notice] Server built: Sep 10 2011 11:34:11
[Fri Jun 08 15:57:37 2012] [notice] Parent: Created child process 3932
[Fri Jun 08 15:57:38 2012] [notice] Digest: generating secret for digest authentication ...
[Fri Jun 08 15:57:38 2012] [notice] Digest: done
[Fri Jun 08 15:57:38 2012] [notice] Child 3932: Child process is running
[Fri Jun 08 15:57:38 2012] [notice] Child 3932: Acquired the start mutex.
[Fri Jun 08 15:57:38 2012] [notice] Child 3932: Starting 150 worker threads.
[Fri Jun 08 15:57:38 2012] [notice] Child 3932: Starting thread to listen on port 80.
[Fri Jun 08 15:57:38 2012] [notice] Child 3932: Starting thread to listen on port 80.

Any thoughts on what I should try, or tools/techniques to trace back to what code, etc. might be causing this?

Scott Szretter
  • 3,938
  • 11
  • 57
  • 76
  • 1
    maybe this will help http://www.java-samples.com/showtutorial.php?tutorialid=1050 – Uku Loskit Jun 08 '12 at 20:08
  • What changed between when it was working and now? – Marcus Adams Jun 08 '12 at 20:21
  • It is working, it just crashes as load increases. If it's just me testing, I basically never see an issue. Once it gets loaded up with 20+ users, that's when it starts having issues. But it still works for them, they just get a communications error every so often (which could mean data loss). – Scott Szretter Jun 09 '12 at 00:04
  • June 8. Is this still occurring? – Cole Tobin Jul 03 '12 at 00:28
  • Yes still happening. I have tried disabling several php extensions, moving those dll's to bin or system32, several optimizations to code, which have improved things, cutting down on the number of crashes, but it is still happening. – Scott Szretter Jul 04 '12 at 02:23
  • Another update, still happening, though I have made the issue less frequent by throwing more hardware at it, optimizing code, using eaccelerator and more. Though it seems I STILL have something buried in there that is literally crashing apache/php, I just cant seem to find it. – Scott Szretter Jan 03 '13 at 01:12

1 Answers1

2

Since XAMPP's Apache (for Windows) is built with winn_nt MPM (multi-thread) + Thread-Safe PHP, it may be that you are hitting a problem inherent to the supposedly Thread-Safe versions of PHP (see this very good post for more information). This could explain why you never encounter the error when running in a single-user mode.

Please let us know if Uku Loskit's suggestion did any good. If not, I would recommend switching to a Prefork + Non-Thread-Safe PHP setup in such a multi-user environment.

Because MPM must be chosen at compile-time, you would need to either:

  • compile Apache yourself (technically feasible, but quite a pain in the neck on Windows, as far as I remember)
  • find a distribution other than XAMPP, which is built with prefork (I do not know any)

Perhaps you'd better try to run PHP with FastCGI (this extra layer basically isolates server threads by starting a separate PHP process for each thread, and much more). This should allow you to verify easily enough my initial assumption.

Just a side note: I do not see the point in installing Apache on a Windows Server. You may want to consider either using IIS, optionally with FastGCI (see instructions here), or (better) switch to a Linux-based stack.

Community
  • 1
  • 1
RandomSeed
  • 29,301
  • 6
  • 52
  • 87
  • I like your answer, though how do I know if this is really a MPM / Thread Safe PHP issue (if turning MPM off would work-around the issue, how do you turn that off in Apache Windows, or is there another recommended work-around)? I found this post which has another couple links about thread safe php issues: http://stackoverflow.com/questions/1623914/what-is-thread-safe-or-non-thread-safe-in-php/5978844#5978844 Another one: http://stackoverflow.com/questions/681081/is-php-thread-safe – Scott Szretter Jan 06 '13 at 12:47