php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8446 PHP/apache process is in infinite loop or appears to suck CPU
Submitted: 2000-12-27 19:31 UTC Modified: 2001-04-10 09:39 UTC
From: michael at audiogalaxy dot com Assigned:
Status: Closed Package: *General Issues
PHP Version: 4.0.4 OS: RH 7.0 and RH 6.2 Any kernel 2.2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: michael at audiogalaxy dot com
New email:
PHP Version: OS:

 

 [2000-12-27 19:31 UTC] michael at audiogalaxy dot com
Below is a report from top for a SMP machine.  This happens to all of our webservers every day or so a few machine have one two httpd processes eating CPU.  This same problem also happens on the last two or more previous versions of php.  

A simple kill -9 pid removes it w/o killing the whole webserver.  Below are the apache and httpd configuration lines:

./configure --with-mysql --enable-track-vars --with-zlib --with-apache=$apachedir --with-gd=$gddir --with-jpeg-dir=$gddir --with-config-file-path=/common/globalconfig/php --enable-memory-limit

./configure --with-layout=production --activate-module=src/modules/php4/libphp4.a

An interesting aspect that is amount of memory each processing using 100% CPU is around 50megs.  We have the memory limit set in php as 30M.

1 processes: 85 sleeping, 6 running, 0 zombie, 0 stopped
CPU0 states: 70.0% user,  4.0% system,  0.0% nice, 25.0% idle
CPU1 states: 53.0% user,  4.0% system,  0.0% nice, 41.0% idle
Mem:  1036464K av, 1006188K used,   30276K free,  149244K shrd,   32068K buff
Swap:  136512K av,    1124K used,  135388K free                  677272K cached

  PID USER     PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME COMMAND
 7763 nobody     9   0 53808  52M  2172 R    99.9  5.1  1527m httpd
 6825 nobody     0   0  4320 4320  2272 S     9.2  0.4   0:00 httpd
 6779 nobody     0   0  4912 4912  2276 S     6.4  0.4   0:00 httpd
 6830 root       4   0  1036 1036   812 R     6.4  0.0   0:00 top


Thanks for your help - this has been a real nagging problem for us that we keep thinking is resolved in the next version.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-12-28 05:31 UTC] derick@php.net
Rasmus replyed:

We cannot possibly track this down for you based on this.  You will need
to attach gdb to one of these looped processes and see where it is
looping.
 [2000-12-28 14:04 UTC] michael at audiogalaxy dot com
Below is the requested information on one of the processes.  I am not running php with --enable-debug - is this a problem?  Should I go back and recompile everything?
Thanks

Attaching to program: /usr/sbin/httpd, Pid 28916
0x2ac1ce2b in ?? ()
(gdb) bt
#0  0x2ac1ce2b in ?? ()
#1  0x2ac1cc94 in ?? ()
#2  0x80dcf59 in do_foreach_cont (value=0xb4b201c, key=0x2acbe8a0, as_token=0x80eecb8) at zend_compile.c:2095
#3  0x80dd41b in do_extended_fcall_begin () at zend_compile.c:2291
#4  0x807e708 in php_execute_script (primary_file=0x0) at main.c:1150
#5  0x807e6bb in php_execute_script (primary_file=0x81a5920) at main.c:1144
#6  0x807cdb5 in php_info_apache (zend_module=0x81ea024) at php_apache.c:269
#7  0x812556e in usage ()
#8  0x812b4fb in ap_read_request ()
#9  0x812e0b2 in ap_rprintf ()
#10 0x812e6fb in ap_send_error_response ()
#11 0x812ea78 in ap_send_error_response ()
#12 0x812efdd in check_safe_file ()
#13 0x812f607 in directory_walk ()
#14 0x2abbae21 in ?? ()
 [2001-01-02 09:25 UTC] sniper@php.net
Yes, you should reconfigure/compile php with --enable-debug
in configure line. And please add also shortest possible
script which causes this infinite loop.

--Jani
 [2001-01-10 05:02 UTC] michael at audiogalaxy dot com
I now added the --enable-debug and here are the following backtraces I get when php/apache is stuck:

example1:
Attaching to program: /usr/sbin/httpd, Pid 3193
0x2ac1d671 in ?? ()
(gdb) bt
#0  0x2ac1d671 in ?? ()
#1  0x2ac1d4d4 in ?? ()
#2  0x81016ca in normal_skipS (enc=0x1, ptr=0x0) at xmltok_impl.c:1694
#3  0x807efe7 in php_global_startup_internal_extensions () at internal_functions.c:68
#4  0x807c637 in init_request_info ()
#5  0x8150470 in utf8_toUtf8 ()
#6  0x814ed2a in normal_scanPoundName ()
#7  0x814edaa in normal_scanPoundName ()
#8  0x814ed16 in normal_scanPoundName ()
#9  0x815e41d in gdImageCopyMergeGray ()
#10 0x815eab3 in gdImageCreateFromXbm ()
#11 0x815ee30 in gdImageCreateFromXbm ()
#12 0x815f395 in gdImageSetTile ()
#13 0x815f9bf in gdImageCharUp ()
#14 0x2abbafd1 in ?? ()
(gdb) 



example2:
(gdb) bt
#0  0x2ac1ce26 in ?? ()
#1  0x2ac1cc94 in ?? ()
#2  0x81016ca in php_XmlInitUnknownEncoding (mem=0x1, table=0x0, convert=0x7ffff898, 
    userData=0x807efbd) at xmltok.c:1313
#3  0x807efe7 in do_cfg_op (type=42 '*', result=0x821cbb4, op1=0x7ffff8d8, op2=0x8153192)
    at configuration-parser.c:389
#4  0x807c637 in php_apache_value_handler_ex ()
#5  0x8150470 in big2_scanComment ()
#6  0x814ed2a in little2_prologTok ()
#7  0x814edaa in little2_prologTok ()
#8  0x815e895 in mime_cmds ()
#9  0x815eab3 in mime_cmds ()
#10 0x815ee30 in negotiation_cmds ()
#11 0x815f395 in status_options ()
#12 0x815f9bf in status_options ()
#13 0x2abbae21 in ?? ()
(gdb) 

Unfortunately there is no way I can attach a script that causes this bug because we have no clue when it happens and it happens only a few times a day on a site that gets 65 million page views per month.  We are using gd version 1.8.3 


 [2001-01-10 05:10 UTC] michael at audiogalaxy dot com
OOPS - please ignore my last post a few minutes on this - The debug symbols did not load properly.

example 1:
Attaching to program: /common/install/httpd, Pid 3193
Reading symbols from /lib/libpam.so.0...done.
Loaded symbols for /lib/libpam.so.0
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /usr/lib/libz.so.1...done.
Loaded symbols for /usr/lib/libz.so.1
Reading symbols from /usr/lib/libpng.so.2...done.
Loaded symbols for /usr/lib/libpng.so.2
Reading symbols from /usr/lib/libjpeg.so.62...done.
Loaded symbols for /usr/lib/libjpeg.so.62
Reading symbols from /lib/libresolv.so.2...done.
Loaded symbols for /lib/libresolv.so.2
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libcrypt.so.1...done.
Loaded symbols for /lib/libcrypt.so.1
Reading symbols from /lib/libnsl.so.1...done.
Loaded symbols for /lib/libnsl.so.1
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /lib/libnss_files.so.2...done.
Loaded symbols for /lib/libnss_files.so.2
Reading symbols from /lib/libnss_nisplus.so.2...done.
Loaded symbols for /lib/libnss_nisplus.so.2
Reading symbols from /lib/libnss_nis.so.2...done.
Loaded symbols for /lib/libnss_nis.so.2
0x2ac1d66e in chunk_free (ar_ptr=0x2acc1f00, p=0xcc1f570) at malloc.c:3142
3142    malloc.c: No such file or directory.
(gdb) bt
#0  0x2ac1d66e in chunk_free (ar_ptr=0x2acc1f00, p=0xcc1f570) at malloc.c:3142
#1  0x2ac1d4d4 in __libc_free (mem=0xcc1f5b8) at malloc.c:3044
#2  0x81016ca in shutdown_memory_manager (silent=1, clean_cache=0) at zend_alloc.c:478
#3  0x807efe7 in php_request_shutdown (dummy=0x0) at main.c:695
#4  0x807c637 in php_apache_request_shutdown ()
#5  0x8150470 in run_cleanups ()
#6  0x814ed2a in ap_clear_pool ()
#7  0x814edaa in ap_destroy_pool ()
#8  0x814ed16 in ap_clear_pool ()
#9  0x815e41d in child_main ()
#10 0x815eab3 in make_child ()
#11 0x815ee30 in perform_idle_server_maintenance ()
#12 0x815f395 in standalone_main ()
#13 0x815f9bf in main ()
#14 0x2abbafd1 in __libc_start_main (main=0x815f628 <main>, argc=1, ubp_av=0x7ffffb64, 
    init=0x8064de0 <_init>, fini=0x819338c <_fini>, rtld_fini=0x2aab9254 <_dl_fini>, 
    stack_end=0x7ffffb5c) at ../sysdeps/generic/libc-start.c:118
(gdb) 


example 2:
Attaching to program: /common/install/httpd, Pid 13835
Reading symbols from /lib/libpam.so.0...done.
Loaded symbols for /lib/libpam.so.0
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /usr/lib/libz.so.1...done.
Loaded symbols for /usr/lib/libz.so.1
Reading symbols from /usr/lib/libpng.so.2...done.
Loaded symbols for /usr/lib/libpng.so.2
Reading symbols from /usr/lib/libjpeg.so.62...done.
Loaded symbols for /usr/lib/libjpeg.so.62
Reading symbols from /lib/libresolv.so.2...done.
Loaded symbols for /lib/libresolv.so.2
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libcrypt.so.1...done.
Loaded symbols for /lib/libcrypt.so.1
Reading symbols from /lib/libnsl.so.1...done.
Loaded symbols for /lib/libnsl.so.1
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /lib/libnss_files.so.2...done.
Loaded symbols for /lib/libnss_files.so.2
Reading symbols from /lib/libnss_nisplus.so.2...done.
Loaded symbols for /lib/libnss_nisplus.so.2
Reading symbols from /lib/libnss_nis.so.2...done.
Loaded symbols for /lib/libnss_nis.so.2
Reading symbols from /lib/libnss_dns.so.2...done.
Loaded symbols for /lib/libnss_dns.so.2
0x2ac1ce26 in chunk_free (ar_ptr=0x2acbe8a0, p=0x82a5ff0) at malloc.c:3142
3142    malloc.c: No such file or directory.
(gdb) bt
#0  0x2ac1ce26 in chunk_free (ar_ptr=0x2acbe8a0, p=0x82a5ff0) at malloc.c:3142
#1  0x2ac1cc94 in __libc_free (mem=0x82a6050) at malloc.c:3044
#2  0x81016ca in shutdown_memory_manager (silent=1, clean_cache=0) at zend_alloc.c:478
#3  0x807efe7 in php_request_shutdown (dummy=0x0) at main.c:695
#4  0x807c637 in php_apache_request_shutdown ()
#5  0x8150470 in run_cleanups ()
#6  0x814ed2a in ap_clear_pool ()
#7  0x814edaa in ap_destroy_pool ()
#8  0x815e895 in child_main ()
#9  0x815eab3 in make_child ()
#10 0x815ee30 in perform_idle_server_maintenance ()
#11 0x815f395 in standalone_main ()
#12 0x815f9bf in main ()
#13 0x2abbae21 in __libc_start_main (main=0x815f628 <main>, argc=1, ubp_av=0x7ffffb64, 
    init=0x8064de0 <_init>, fini=0x819338c <_fini>, rtld_fini=0x2aab8f94 <_dl_fini>, 
    stack_end=0x7ffffb5c) at ../sysdeps/generic/libc-start.c:111
(gdb) 


This also looks like the same bug as #8618

Thanks


 [2001-01-12 22:58 UTC] michael at audiogalaxy dot com
Another example - this time where memory usage is low while eating as much CPU as it can:

Reading symbols from /lib/libnss_nis.so.2...done.
Loaded symbols for /lib/libnss_nis.so.2
0x2ac1ce20 in chunk_free (ar_ptr=0x2acbe8a0, p=0x82097a0) at malloc.c:3142
3142    malloc.c: No such file or directory.
(gdb) bt
#0  0x2ac1ce20 in chunk_free (ar_ptr=0x2acbe8a0, p=0x82097a0) at malloc.c:3142
#1  0x2ac1cc94 in __libc_free (mem=0x8209958) at malloc.c:3044
#2  0x80eb4bb in zend_hash_destroy (ht=0x81d0b00) at zend_hash.c:569
#3  0x807fee4 in php_shutdown_config () at php_ini.c:244
#4  0x807e6d5 in php_module_shutdown () at main.c:941
#5  0x807e6bb in php_module_shutdown_wrapper (sapi_globals=0x81a5920) at main.c:926
#6  0x807cdb5 in php_child_exit_handler ()
#7  0x812556e in ap_child_exit_modules ()
#8  0x812b4fb in clean_child_exit ()
#9  0x812e0b2 in child_main ()
#10 0x812e6fb in make_child ()
#11 0x812ea78 in perform_idle_server_maintenance ()
#12 0x812efdd in standalone_main ()
#13 0x812f607 in main ()
#14 0x2abbae21 in __libc_start_main (main=0x812f270 <main>, argc=2, ubp_av=0x7ffffb24, init=0x8064c2c <_init>, 
    fini=0x8162fdc <_fini>, rtld_fini=0x2aab8f94 <_dl_fini>, stack_end=0x7ffffb1c)
    at ../sysdeps/generic/libc-start.c:111
(gdb) q
 [2001-03-04 16:11 UTC] sniper@php.net
Could you please try the latest CVS snapshot from http://snaps.php.net/ ?

--Jani

 [2001-04-10 09:39 UTC] sniper@php.net
No feedback. If this happens with soon to be released PHP 4.0.5 too, reopen this bug report.

--Jani

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Feb 05 14:01:32 2025 UTC