How do I correct Application Errors in module php4ts.dll in Apache.exe?

Posted on 2007-10-11
Last Modified: 2012-05-05
I'm a Windows Server Administrator, but actually a client has a Apache for Windows in a Windows Server 2003 R2.

An event is registered in the application section of Event Viewer, when we got some concurrent users on a apache site (with php based applications):  

Tipo de suceso:      Error
Origen del suceso:      Application Error
Categoría del suceso:      (100)
Id. suceso:      1000
Fecha:            02/10/2007
Hora:            9:37:51
Usuario:            No disponible
Equipo:      DCSERVER2
Aplicación con errores: Apache.exe, versión:, módulo con error: php4ts.dll, versión, dirección de error 0x000c6aa2.

Para obtener más información, vea el Centro de ayuda y soporte técnico en
0000: 41 70 70 6c 69 63 61 74   Applicat
0008: 69 6f 6e 20 46 61 69 6c   ion Fail
0010: 75 72 65 20 20 41 70 61   ure  Apa
0018: 63 68 65 2e 65 78 65 20   che.exe
0020: 32 2e 30 2e 35 30 2e 30
0028: 20 69 6e 20 70 68 70 34    in php4
0030: 74 73 2e 64 6c 6c 20 34   ts.dll 4
0038: 2e 34 2e 34 2e 34 20 61   .4.4.4 a
0040: 74 20 6f 66 66 73 65 74   t offset
0048: 20 30 30 30 63 36 61 61    000c6aa
0050: 32                        2      

Where else i could find log information about this Windows Error.  Do you need any log?

Thanks in advance for your help
Question by:bad3000
    LVL 3

    Expert Comment

    You could look in the apache error log (this can be set in either the server config or VirtualHost definiton).
    If the php ini setting log_errors is On then php errors are logged in the apache error log, but i suspect this is a segmentation fault in which case you might not find anything in the apache error logs.
    php4 had a lot of bugs causing segmentation faults on windows threaded webservers (some of which i've encounter were related to  preg_match_all() and ereg_replace() or mb_ereg_replace() functions)

    You should update to the latest release of php4 and see if the problem persists.

    If you are running a publicly available/open source php application you could check out the community forums and see if anyone else has similar problems.

    If it's a custom build php application ask the developer(s) to test using a debug build of php and webserver stress test tools.

    As a short term fix, you could set ThreadsPerChild 1 for mpm_winnt.c. That will most likely stop the errors from occurring but it will affect performance during high concurrency. To regain some of the lost performance you could increase the MaxClients value but this approach will use more ram compared to threads.
    LVL 1

    Author Comment

    I've found this setting on the php.ini
    ;memory_limit = 128M      ; Maximum amount of memory a script may consume (128MB)

    I'noticed that after 128MB Apache.exe also fails, it could happen?  I'm testing now with a Memory Limit of 512M

    I'm new to php.ini settings.  Can you explain where are the files that i need to change and how i can set the MaxClients settings, a sample it's good, it's HEX o DEC, how can i write the MaxClient seting?


    LVL 3

    Accepted Solution

    I don't think this is related to the memory_limit setting. If you were hitting the memory limit, php would not cause an application error and you would be able to see the error message in the apache error logs (log_errors is enabled by default in php windows installations)
    The default apache 2.0 instalation path is C:\Program Files\Apache Group\Apache2.
    You should check C:\Program Files\Apache Group\Apache2\logs\error.log and C:\Program Files\Apache Group\Apache2\error_log. If memory limit was hit then you will find Fatal Error entries in error_log.
    (Note, error_log is the default error log set up by apache, it can - and usually is - changed in VirtualHost directives in httpd.conf)

    The MaxClients and ServerLimit directives are normally set in httpd.conf ( C:\Program Files\Apache Group\Apache2\conf\httpd.conf) but i was misinformed because mpm_winnt does not spawn more than 1 child process and does not support these settings. You could increase ThreadsPerChild to achieve something similar to the MaxClients directive. Setting ThreadsPerChild to 1 (as recommended by me in my first post) will reduce the performace of your webserver to a crawl. Search for <IfModule mpm_winnt.c>. In apache 2.2 these settings are no longer in a <IfModule> directive because mpm_winnt is the only multi processing module available for windows. To

    Hitting memory limit should not cause an application error and should not cause apache to crash. A memory limit of 512mb for a php application is way too much and apache will try to allocate this much memory for each php execution thread. memory_limit is not a global setting affecting the overall php memory usage, it refers to the memory limit of each php thread/process. 512mb is a lot of memory to be used by a script generating a html page but it might be required, i don't know what your application is doing (just seems excessive), but during high concurrency if your scripts do use up 512mb of ram each, you will need a lot of ram. The apache server should not normally fail if a php script has hit memory limit. I do not know what would happen if apache would try to allocate more memory than maximum memory available on the system.

    If there's nothing in the error logs related to the crash, to find out wich script file is causing the error check the access logs and test most accessed script files with ab (Apache Bench, installed by default with apache in C:\Program Files\Apache Group\Apache2\bin\ab.exe or abs.exe for ssl).

    ab.exe -c 10 -t 30 htttp://domain/script.php will hammer script.php with requests for 30 seconds with 10 concurrency. Replace domain with your domain name and script.php with the script file you want to test. you can also add get parameters, please see the ApacheBench documentation on how to test post requests. if you only have one site configured for apache you can test with localhost instead of public domain name. You can increase concurrency and find out exactly what part of your php application is causing the crash.

    I'm sorry about my initial uninformed statement about the MaxClients directive. I assumed it was the same  for all multiprocessing modules.

    I strongly recommend you update to php 4.4.7 several segmentation fault errors have been fixed since 4.4.4 - - (i'm assuming this is the version you are using based on the error report php4ts.dll version number)
    LVL 1

    Author Comment

    We actually downloaded and installed the php 4.4.7 but we need to wait until end-of-month processing to see if the application error ocurrs.

    We set the memory limit to 48M on the previos month processing and we noticed that the number of times that the application error was reduced from 10 by day to just once or two by day.

    I didn't review the logs yet, we'll wait until this month processing, we enabled the logs as you instructed.  So we are testing, we'll use the stress tool tonight




    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now