php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57581 Apache dies with exit signal Bus error (7) [with Ramdisk]
Submitted: 2007-03-19 13:17 UTC Modified: 2007-03-21 15:23 UTC
From: pbugs at ausschlafen dot com Assigned:
Status: Closed Package: APC (PECL)
PHP Version: Irrelevant OS: Linux 2.4.16-64GB-SMP
Private report: No CVE-ID: None
 [2007-03-19 13:17 UTC] pbugs at ausschlafen dot com
Description:
------------
Hi,

I tried to upgrade APC and php together. What I have is
php 4.4.6 and APC 3.0.13, running under Apache 1.3.37.

I took a sample of all unique GET URLs of my live site and
replayed them on the test server, so the test is not run
in a high load environment. 

Nevertheless, sooner or later during the replay, apache childs crash with :
[notice] child pid 30366 exit signal Bus error (7)

As long as the APC console is working, it does not show
any problem; no fragmentation and the memory usage is
not more than 50% of the 64 MB I assigned to APC.

After the errors occur, the server is unstable. Static
files can be served, but the APC console (and most - but not all- other php apps and scripts) don't work any more.
The crashes do not always occur at the same step of the
URL replay; in this respect I can not pinpoint a single
script or application. However, multiple test runs
repeatedly failed sooner or later.

Apache has to be restarted then.

Occasionally I see [apc-error] Cannot redeclare classes in the Apache error log when some wordpress blogs are accessed. The PHP error log remains empty (E_ALL), however. These happen to appear shortly before the "Bus errors", but I don't know whether there is a connection to the crash or not.

My APC settings:
configured with 
./configure --enable-apc --enable-apc-mmap --with-apxs=...

php.ini:

extension="apc.so"
apc.enabled=1
apc.shm_segments=1
apc.optimization=0
apc.shm_size=64
apc.ttl=7600
apc.user_ttl=3600
apc.gc_ttl=3600
apc.num_files_hint=1500
apc.user_entries_hint=100
apc.mmap_file_mask=/mnt/ramdisk/apc13.XXXXXX
apc.enable_cli=0
;apc.cache_by_default=Off
apc.filters="-/some/useless/path/"
; DEPRECATED now write_lock apc.slam_defense=20
apc.file_update_protection=5
apc.max_file_size=1M
apc.stat=1
apc.write_lock=1

The user cache is not used at all.





Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-19 14:19 UTC] pbugs at ausschlafen dot com
Well, I was able to produce a backtrace in part; I had to
transfer the core (including all the source and compile tree)  to a remote machine . Hopfully sheds some light on the problem.


This GDB was configured as "i386-linux"...(no debugging symbols found)...
Core was generated by `/usr/local/apache-beta/bin/httpd'.
Program terminated with signal 7, Bus error.
Error while mapping shared library sections:
/lib/libz.so.1: No such file or directory.
Error while mapping shared library sections:
/opt/pcre//lib/libpcre.so.0: No such file or directory.
Reading symbols from /lib/libm.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libcrypt.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib/libcrypt.so.1
Reading symbols from /usr/lib/libgdbm.so.2...(no debugging symbols found)...
done.
Loaded symbols for /usr/lib/libgdbm.so.2
Reading symbols from /usr/lib/libexpat.so.0...(no debugging symbols found)...
done.
Loaded symbols for /usr/lib/libexpat.so.0
Reading symbols from /lib/libdl.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /lib/libnsl.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib/libnsl.so.1
Reading symbols from /lib/libnss_compat.so.2...(no debugging symbols found)...
done.
Loaded symbols for /lib/libnss_compat.so.2
Reading symbols from /lib/libpthread.so.0...(no debugging symbols found)...
done.
Loaded symbols for /lib/libpthread.so.0
---Type <return> to continue, or q <return> to quit---
Reading symbols from /usr/local/apache-beta/libexec/libphp4.so...
(no debugging symbols found)...done.
Loaded symbols for /usr/local/apache-beta/libexec/libphp4.so
Error while reading shared library symbols:
/lib/libz.so.1: No such file or directory.
Error while reading shared library symbols:
/opt/pcre//lib/libpcre.so.0: No such file or directory.
Reading symbols from /lib/libresolv.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib/libresolv.so.2
Reading symbols from /usr/local/apache-beta/php4/lib/php/extensions/no-debug-non
-zts-20020429/apc.so...done.
Loaded symbols for /usr/local/apache-beta/php4/lib/php/extensions/no-debug-non-z
ts-20020429/apc.so
Reading symbols from /lib/librt.so.1...done.
Loaded symbols for /lib/librt.so.1
#0  sma_allocate (shmaddr=0x40423000, size=84)
    at /usr/local/src/APC-3.0.13/apc_sma.c:155
155             if (cur->size == realsize || (cur->size > (sizeof(block_t) + rea
lsize))) {
(gdb)
(gdb) bt full
#0  sma_allocate (shmaddr=0x40423000, size=84)
    at /usr/local/src/APC-3.0.13/apc_sma.c:155
        size = 1110151204
        prv = (block_t *) 0x40423010
        cur = (block_t *) 0x422b9024
        prvnextfit = (block_t *) 0x0
        realsize = 104
        last_offset = 0
        wrapped = 0
#1  0x403f63a9 in apc_sma_malloc (n=84)
    at /usr/local/src/APC-3.0.13/apc_sma.c:404
        off = 1078079504
        i = 1077896704
#2  0x403f31ac in apc_copy_op_array (dst=0x0, src=0x814a64c,
    allocate=0x403f6350 <apc_sma_malloc>, deallocate=0x403f6600 <apc_sma_free>)
    at /usr/local/src/APC-3.0.13/apc_compile.c:1102
        i = 1077896704
        local_dst_alloc = 0
#3  0x403f4f39 in my_compile_file (h=0xbfff0c78, type=2)
    at /usr/local/src/APC-3.0.13/apc_main.c:408
        key = {data = {file = {device = 2052, inode = 4992943}, user = {
      identifier = 0x804 <Address 0x804 out of bounds>, identifier_len = 0},
    fpfile = {fullpath = 0x804 <Address 0x804 out of bounds>,
---Type <return> to continue, or q <return> to quit---
      fullpath_len = 0}}, mtime = 1173710679, type = 1 '\001'}
        cache_entry = (apc_cache_entry_t *) 0x0
        op_array = (zend_op_array *) 0x814a64c
        num_functions = 693
        num_classes = 3
        ret = 1077896704
        alloc_op_array = (zend_op_array *) 0xbfff0c50
        alloc_functions = (apc_function_t *) 0x402ceb20
        alloc_classes = (apc_class_t *) 0x403f6350
        t = 1174329496
        path = 0x0
        mem_size = 0
#4  0x402b7d72 in compile_filename ()
   from /usr/local/apache-beta/libexec/libphp4.so
No symbol table info available.
#5  0x402e2300 in execute () from /usr/local/apache-beta/libexec/libphp4.so
No symbol table info available.
#6  0x402cb788 in zend_execute_scripts ()
   from /usr/local/apache-beta/libexec/libphp4.so
No symbol table info available.
#7  0x402a403a in php_execute_script ()
   from /usr/local/apache-beta/libexec/libphp4.so
No symbol table info available.
---Type <return> to continue, or q <return> to quit---
#8  0x402e422a in apache_php_module_main ()
   from /usr/local/apache-beta/libexec/libphp4.so
No symbol table info available.
#9  0x402e4ce3 in apache_php_module_main ()
   from /usr/local/apache-beta/libexec/libphp4.so
No symbol table info available.
#10 0x402e4d36 in apache_php_module_main ()
   from /usr/local/apache-beta/libexec/libphp4.so
No symbol table info available.
#11 0x08070679 in ap_invoke_handler ()
No symbol table info available.
#12 0x08087452 in ap_run_sub_req ()
No symbol table info available.
#13 0x0805594b in ap_get_server_built ()
No symbol table info available.
#14 0x08058c8c in ap_get_server_built ()
No symbol table info available.
#15 0x080592f6 in ap_get_server_built ()
No symbol table info available.
#16 0x08070679 in ap_invoke_handler ()
No symbol table info available.
#17 0x08087e9c in ap_some_auth_required ()
No symbol table info available.
---Type <return> to continue, or q <return> to quit---
#18 0x08088350 in ap_internal_redirect ()
No symbol table info available.
#19 0x0805cb5c in ap_get_server_built ()
No symbol table info available.
#20 0x08070679 in ap_invoke_handler ()
No symbol table info available.
#21 0x08087e9c in ap_some_auth_required ()
No symbol table info available.
#22 0x08087f12 in ap_process_request ()
No symbol table info available.
#23 0x0807dfe0 in ap_child_terminate ()
No symbol table info available.
#24 0x0807e25a in ap_child_terminate ()
No symbol table info available.
#25 0x0807e608 in ap_child_terminate ()
No symbol table info available.
#26 0x0807ec7c in ap_child_terminate ()
No symbol table info available.
#27 0x0807f2cc in main ()
No symbol table info available.
#28 0x400b57ee in iconv_close () from /lib/libc.so.6
No symbol table info available.
 [2007-03-19 21:38 UTC] gopalv82 at yahoo dot com
Can you apply these three patches 

http://news.php.net/php.pecl.cvs/7416
http://news.php.net/php.pecl.cvs/7418
http://news.php.net/php.pecl.cvs/7412

and test again ?

And as long as it is in a non-prod environment, a 
rebuild with CFLAGS="-D__APC_SMA_DEBUG__" will choke
the logs with some info which might be useful for me
post-mortem.
 [2007-03-20 05:03 UTC] pbugs at ausschlafen dot com
Thanks for pointing out the patches. I'll try them out.
Before doing that, let me report one change that seemed
to be important. I had  
apc.mmap_file_mask=/mnt/ramdisk/apc13.XXXXXX
which is on a ramdisk. This ramdisk is also used by
other apps (template cache etc.)  Although I have not
found any error messages in the syslog (like "file system
full" etc.) or anywhere else, it might be possible that
the ramdisk filled up. So I changed the setting to
apc.mmap_file_mask=/somepath/on/disk/apc13.XXXXXX
and since then my test suite ran fine for four times in a
row.  The only problem was the occasional "redeclare" error,
leading to blank pages in Wordpress - but without killing
apache.

OK, now I'll try the patches, and then , out of curiousity
I will switch back to the ramdisk config and see what happens.

Regards
Ulrich
 [2007-03-20 05:18 UTC] gopalv82 at yahoo dot com
Since I'm too lazy to set up wordpress on my php debug builds, let me ask what is the full redeclare class error message ?
 [2007-03-20 06:51 UTC] pbugs at ausschlafen dot com
Hello again,

here we go:

First, I used the unpatched .13 version with the ramdisk config, ran my test suite (no problems) and then filled the ramdisk with some files - bingo, crashed as described.

Then, I applied your patches and recompiled with your CFLAGS; actually I set both CFLAGS and CPPFLAGS because I wasn't sure. (this apc.so came out 1/3 the size of
the previous - 90kB instead of 270)

Then I ran the testsuite again, the results were the same:
- running with apc.mmap_file_mask=/mnt/ramdisk/apc13.XXXXXX
crashes as soon as the ramdisk is full
- running with apc.mmap_file_mask on a local disk path
does not crash (but still has redeclare errors)


For some reason the patched version with the different compile settings did not produce a core dump,
only the "child pid 5053 exit signal Bus error" lines.

Before the first child crash, there were multiple  debug
lines in the apache error logs (included at the bottom
of this report). After the first crash, no more of these debug entries appeared.


Other observations:

the php error log remained empty (even with E_ALL), 
the "cannot redeclare" still popped up in the apache error log, so some wordpress pages did not work (probably caused
by a WP plugin, since it only occured in one specific blog)

Regarding this bug report :
It's up to you whether this bug should be closed due to
the fact that it was probably only a simple diskspace issue 
(sorry for that!) or whether it should be turned into a
Feature request to handle this situation in a graceful manner. 

Out of curiosity I set apc.shm_size to a very low value
and re-run my test. Of course the hit rate dropped and the console now showed values like:
 Free: 104.0 Bytes (0.0%) 	 
 Used: 16.0 MBytes (100.0%)
But this did not cause any error/crash, so it handles
this situation just fine.


Should I post another report for the "redeclare" problem?
As far as I could see in the archives this problem was supposed to be solved. Since it only affects some scripts
and not the whole server, it can be fixed by applying
filter, but then it would be helpful if APC would also write the file name into the error message.

Regards,
Ulrich

And this is the debug output I mentioned. After
the first "Bus error", no more "allocate" lines
appear in the log. These are the last couple of
lines before the first Bus error. There were not
lines containing free() in the log, just allocate().


allocate(realsize=6,size=24,id=3119)
allocate(realsize=7,size=24,id=3120)
allocate(realsize=10,size=32,id=3121)
allocate(realsize=9,size=32,id=3122)
allocate(realsize=7,size=24,id=3123)
allocate(realsize=6,size=24,id=3124)
allocate(realsize=7,size=24,id=3125)
allocate(realsize=6,size=24,id=3126)
allocate(realsize=4,size=24,id=3127)
allocate(realsize=6,size=24,id=3128)
allocate(realsize=7,size=24,id=3129)
allocate(realsize=7,size=24,id=3130)
allocate(realsize=7,size=24,id=3131)
allocate(realsize=10,size=32,id=3132)
allocate(realsize=15,size=32,id=3133)
allocate(realsize=7,size=24,id=3134)
allocate(realsize=7,size=24,id=3135)
allocate(realsize=7,size=24,id=3136)
allocate(realsize=7,size=24,id=3137)
allocate(realsize=4,size=24,id=3138)
allocate(realsize=7,size=24,id=3139)
allocate(realsize=7,size=24,id=3140)
allocate(realsize=9,size=32,id=3141)
allocate(realsize=7,size=24,id=3142)
allocate(realsize=9,size=32,id=3143)
allocate(realsize=1,size=24,id=3144)
allocate(realsize=7,size=24,id=3145)
allocate(realsize=9,size=32,id=3146)
allocate(realsize=4,size=24,id=3147)
allocate(realsize=6,size=24,id=3148)
allocate(realsize=7,size=24,id=3149)
allocate(realsize=9,size=32,id=3150)
allocate(realsize=5,size=24,id=3151)
allocate(realsize=6,size=24,id=3152)
allocate(realsize=6,size=24,id=3153)
allocate(realsize=6,size=24,id=3154)
allocate(realsize=2,size=24,id=3155)
allocate(realsize=6,size=24,id=3156)
allocate(realsize=2,size=24,id=3157)
allocate(realsize=7,size=24,id=3158)
allocate(realsize=2,size=24,id=3159)
allocate(realsize=11,size=32,id=3160)
allocate(realsize=2,size=24,id=3161)
allocate(realsize=5,size=24,id=3162)
allocate(realsize=7,size=24,id=3163)
allocate(realsize=7,size=24,id=3164)
allocate(realsize=20,size=40,id=3165)
allocate(realsize=28,size=48,id=3166)
allocate(realsize=63,size=80,id=3167)
allocate(realsize=44,size=64,id=3168)
allocate(realsize=84,size=104,id=3169)
allocate(realsize=92,size=112,id=3170)
allocate(realsize=4,size=24,id=3171)
allocate(realsize=360,size=376,id=3172)
allocate(realsize=48,size=64,id=3173)
allocate(realsize=3,size=24,id=3174)
allocate(realsize=386,size=408,id=3175)
allocate(realsize=3,size=24,id=3176)
allocate(realsize=104,size=120,id=3177)
allocate(realsize=12,size=32,id=3178)
allocate(realsize=20,size=40,id=3179)
allocate(realsize=28,size=48,id=3180)
allocate(realsize=92,size=112,id=3181)
allocate(realsize=44,size=64,id=3182)
allocate(realsize=84,size=104,id=3183)
allocate(realsize=111,size=128,id=3184)
allocate(realsize=4,size=24,id=3185)
allocate(realsize=120,size=136,id=3186)
allocate(realsize=188,size=208,id=3187)
allocate(realsize=12,size=32,id=3188)
allocate(realsize=20,size=40,id=3189)
allocate(realsize=28,size=48,id=3190)
allocate(realsize=111,size=128,id=3191)
allocate(realsize=44,size=64,id=3192)
allocate(realsize=84,size=104,id=3193)
allocate(realsize=93,size=112,id=3194)
allocate(realsize=4,size=24,id=3195)
allocate(realsize=4140,size=4160,id=3196)
allocate(realsize=408,size=424,id=3197)
allocate(realsize=407,size=424,id=3198)
allocate(realsize=411,size=432,id=3199)
allocate(realsize=407,size=424,id=3200)
allocate(realsize=65,size=88,id=3201)
allocate(realsize=5,size=24,id=3202)
allocate(realsize=10,size=32,id=3203)
allocate(realsize=17,size=40,id=3204)
allocate(realsize=5,size=24,id=3205)
allocate(realsize=16,size=32,id=3206)
allocate(realsize=27,size=48,id=3207)
allocate(realsize=9,size=32,id=3208)
allocate(realsize=16,size=32,id=3209)
allocate(realsize=5,size=24,id=3210)
allocate(realsize=8,size=24,id=3211)
allocate(realsize=5,size=24,id=3212)
allocate(realsize=12,size=32,id=3213)
allocate(realsize=9,size=32,id=3214)
allocate(realsize=24,size=40,id=3215)
allocate(realsize=20,size=40,id=3216)
allocate(realsize=17,size=40,id=3217)
allocate(realsize=5,size=24,id=3218)
allocate(realsize=10,size=32,id=3219)
allocate(realsize=17,size=40,id=3220)
allocate(realsize=5,size=24,id=3221)
allocate(realsize=10,size=32,id=3222)
allocate(realsize=17,size=40,id=3223)
allocate(realsize=5,size=24,id=3224)
allocate(realsize=16,size=32,id=3225)
allocate(realsize=27,size=48,id=3226)
allocate(realsize=9,size=32,id=3227)
allocate(realsize=2,size=24,id=3228)
allocate(realsize=5,size=24,id=3229)
allocate(realsize=8,size=24,id=3230)
allocate(realsize=5,size=24,id=3231)
allocate(realsize=17,size=40,id=3232)
allocate(realsize=12,size=32,id=3233)
allocate(realsize=5,size=24,id=3234)
allocate(realsize=8,size=24,id=3235)
allocate(realsize=5,size=24,id=3236)
allocate(realsize=21,size=40,id=3237)
allocate(realsize=24,size=40,id=3238)
allocate(realsize=20,size=40,id=3239)
allocate(realsize=17,size=40,id=3240)
allocate(realsize=5,size=24,id=3241)
allocate(realsize=10,size=32,id=3242)
allocate(realsize=17,size=40,id=3243)
allocate(realsize=73,size=96,id=3244)
allocate(realsize=12,size=32,id=3245)
allocate(realsize=20,size=40,id=3246)
allocate(realsize=28,size=48,id=3247)
allocate(realsize=93,size=112,id=3248)
allocate(realsize=44,size=64,id=3249)
allocate(realsize=84,size=104,id=3250)
allocate(realsize=90,size=112,id=3251)
allocate(realsize=4,size=24,id=3252)
allocate(realsize=3000,size=3016,id=3253)
allocate(realsize=101,size=120,id=3254)
allocate(realsize=3,size=24,id=3255)
allocate(realsize=25,size=48,id=3256)
allocate(realsize=3,size=24,id=3257)
allocate(realsize=403,size=424,id=3258)
allocate(realsize=406,size=424,id=3259)
allocate(realsize=138,size=160,id=3260)
allocate(realsize=3,size=24,id=3261)
allocate(realsize=25,size=48,id=3262)
allocate(realsize=3,size=24,id=3263)
allocate(realsize=403,size=424,id=3264)
allocate(realsize=406,size=424,id=3265)
allocate(realsize=138,size=160,id=3266)
allocate(realsize=3,size=24,id=3267)
allocate(realsize=25,size=48,id=3268)
allocate(realsize=3,size=24,id=3269)
allocate(realsize=403,size=424,id=3270)
allocate(realsize=406,size=424,id=3271)
allocate(realsize=138,size=160,id=3272)
allocate(realsize=3,size=24,id=3273)
allocate(realsize=25,size=48,id=3274)
allocate(realsize=3,size=24,id=3275)
allocate(realsize=403,size=424,id=3276)
allocate(realsize=406,size=424,id=3277)
allocate(realsize=140,size=160,id=3278)
allocate(realsize=3,size=24,id=3279)
allocate(realsize=25,size=48,id=3280)
allocate(realsize=3,size=24,id=3281)
allocate(realsize=403,size=424,id=3282)
allocate(realsize=406,size=424,id=3283)
allocate(realsize=140,size=160,id=3284)
allocate(realsize=3,size=24,id=3285)
allocate(realsize=25,size=48,id=3286)
allocate(realsize=3,size=24,id=3287)
allocate(realsize=403,size=424,id=3288)
allocate(realsize=406,size=424,id=3289)
allocate(realsize=140,size=160,id=3290)
allocate(realsize=3,size=24,id=3291)
allocate(realsize=25,size=48,id=3292)
allocate(realsize=3,size=24,id=3293)
allocate(realsize=403,size=424,id=3294)
allocate(realsize=406,size=424,id=3295)
allocate(realsize=140,size=160,id=3296)
allocate(realsize=3,size=24,id=3297)
allocate(realsize=25,size=48,id=3298)
allocate(realsize=3,size=24,id=3299)
allocate(realsize=403,size=424,id=3300)
allocate(realsize=406,size=424,id=3301)
allocate(realsize=153,size=176,id=3302)
allocate(realsize=12,size=32,id=3303)
allocate(realsize=20,size=40,id=3304)
allocate(realsize=28,size=48,id=3305)
allocate(realsize=90,size=112,id=3306)
allocate(realsize=44,size=64,id=3307)
allocate(realsize=84,size=104,id=3308)
allocate(realsize=95,size=112,id=3309)
allocate(realsize=4,size=24,id=3310)
allocate(realsize=60,size=80,id=3311)
allocate(realsize=12,size=32,id=3312)
allocate(realsize=20,size=40,id=3313)
allocate(realsize=28,size=48,id=3314)
allocate(realsize=95,size=112,id=3315)
allocate(realsize=44,size=64,id=3316)
allocate(realsize=84,size=104,id=3317)
allocate(realsize=92,size=112,id=3318)
allocate(realsize=4,size=24,id=3319)
allocate(realsize=3180,size=3200,id=3320)
allocate(realsize=61,size=80,id=3321)
allocate(realsize=5,size=24,id=3322)
allocate(realsize=10,size=32,id=3323)
allocate(realsize=17,size=40,id=3324)
allocate(realsize=5,size=24,id=3325)
allocate(realsize=16,size=32,id=3326)
allocate(realsize=27,size=48,id=3327)
allocate(realsize=9,size=32,id=3328)
allocate(realsize=30,size=48,id=3329)
allocate(realsize=24,size=40,id=3330)
allocate(realsize=20,size=40,id=3331)
allocate(realsize=17,size=40,id=3332)
allocate(realsize=5,size=24,id=3333)
allocate(realsize=10,size=32,id=3334)
allocate(realsize=17,size=40,id=3335)
allocate(realsize=58,size=80,id=3336)
allocate(realsize=5,size=24,id=3337)
allocate(realsize=10,size=32,id=3338)
allocate(realsize=17,size=40,id=3339)
allocate(realsize=5,size=24,id=3340)
allocate(realsize=16,size=32,id=3341)
allocate(realsize=27,size=48,id=3342)
allocate(realsize=9,size=32,id=3343)
allocate(realsize=16,size=32,id=3344)
allocate(realsize=5,size=24,id=3345)
allocate(realsize=8,size=24,id=3346)
allocate(realsize=5,size=24,id=3347)
allocate(realsize=12,size=32,id=3348)
allocate(realsize=13,size=32,id=3349)
allocate(realsize=24,size=40,id=3350)
allocate(realsize=20,size=40,id=3351)
allocate(realsize=17,size=40,id=3352)
allocate(realsize=5,size=24,id=3353)
allocate(realsize=10,size=32,id=3354)
allocate(realsize=17,size=40,id=3355)
allocate(realsize=50,size=72,id=3356)
allocate(realsize=12,size=32,id=3357)
allocate(realsize=20,size=40,id=3358)
allocate(realsize=28,size=48,id=3359)
allocate(realsize=92,size=112,id=3360)
allocate(realsize=44,size=64,id=3361)
allocate(realsize=84,size=104,id=3362)
allocate(realsize=100,size=120,id=3363)
allocate(realsize=4,size=24,id=3364)
allocate(realsize=240,size=256,id=3365)
allocate(realsize=55,size=72,id=3366)
allocate(realsize=3,size=24,id=3367)
allocate(realsize=336,size=352,id=3368)
allocate(realsize=12,size=32,id=3369)
allocate(realsize=20,size=40,id=3370)
allocate(realsize=28,size=48,id=3371)
allocate(realsize=100,size=120,id=3372)
allocate(realsize=44,size=64,id=3373)
allocate(realsize=84,size=104,id=3374)
allocate(realsize=94,size=112,id=3375)
allocate(realsize=4,size=24,id=3376)
allocate(realsize=780,size=800,id=3377)
allocate(realsize=106,size=128,id=3378)
allocate(realsize=3,size=24,id=3379)
allocate(realsize=20,size=40,id=3380)
allocate(realsize=3,size=24,id=3381)
allocate(realsize=179,size=200,id=3382)
allocate(realsize=3,size=24,id=3383)
allocate(realsize=409,size=432,id=3384)
allocate(realsize=29,size=48,id=3385)
allocate(realsize=3,size=24,id=3386)
allocate(realsize=355,size=376,id=3387)
allocate(realsize=3,size=24,id=3388)
allocate(realsize=162,size=184,id=3389)
allocate(realsize=12,size=32,id=3390)
allocate(realsize=20,size=40,id=3391)
allocate(realsize=28,size=48,id=3392)
allocate(realsize=94,size=112,id=3393)
allocate(realsize=44,size=64,id=3394)
allocate(realsize=84,size=104,id=3)
allocate(realsize=97,size=120,id=4)
allocate(realsize=4,size=24,id=5)
[Tue Mar 20 12:01:36 2007] [notice] child pid 2558 exit signal Bus error (7)
[Tue Mar 20 12:01:36 2007] [notice] child pid 2557 exit signal Bus error (7)
[Tue Mar 20 12:02:06 2007] [notice] child pid 2559 exit signal Bus error (7)
[...] and so on.
 [2007-03-20 06:54 UTC] pbugs at ausschlafen dot com
I just saw your question regarding WP;
the complete error message ist just:

[apc-error] Cannot redeclare class

As I said, there is no php error log entry. The global
error reporting is E_ALL on this test server, but I 
don't know whether WP changes it. If it is interesting
to you, I'll check it out.
 [2007-03-20 07:08 UTC] gopalv82 at yahoo dot com
This shouldn't be happening, but still apply this patch and try again.

--- apc_main.c	15 Mar 2007 22:11:55 -0000	3.95
+++ apc_main.c	20 Mar 2007 11:58:09 -0000
@@ -191,7 +191,11 @@
 #endif                           
 
     if (status == FAILURE) {
-        apc_eprint("Cannot redeclare class %s", cl.name);
+        //apc_eprint("Cannot redeclare class %s", cl.name);
+        apc_eprint("Cannot redeclare class '%s%s'", 
+            (cl.name[0] == 0 && cl.name_len != 0) ? "\0" : "",
+            (cl.name[0] == 0 && cl.name_len != 0) ? &(cl.name[1]) : cl.name
+            );
     } 
     return status;
 }

or you could put an assert(0); instead of the printf and get a coredump from the abort handler, a back trace of that should be able to tell you what the file was. (if you want some help with gdb'ing, I'm g0pz on #php.pecl on EFnet)
 [2007-03-20 07:09 UTC] gopalv82 at yahoo dot com
Argh!, make that \0 as \\0
 [2007-03-20 07:19 UTC] pbugs at ausschlafen dot com
Just to let you know ... there is just one single
place to change error reporting in WP (settings.php)
I set it to E_ALL and there is no error message
in the php errorlog.
 [2007-03-20 08:37 UTC] pbugs at ausschlafen dot com
Hi again,

I changed the error message with your patch, it now is:

[apc-error] Cannot redeclare class '\0cachemeta/path/to/blog/wp-content/wp-cache-config.php25'

The whole WP installation has only one class definition
for CacheMeta. This is checked for with class_exists.
Look here:

cd pathtoblog
grep -irn cachemeta * | grep -v /cache/wp-cache

wp-content/advanced-cache.php:
32:               $meta = new CacheMeta;

wp-content/plugins/wp-cache/wp-cache-phase1.php:
32:             $meta = new CacheMeta;

wp-content/plugins/wp-cache/wp-cache-phase2.php:
39:     $wp_cache_meta_object = new CacheMeta;

wp-content/plugins/wp-cache/wp-cache-phase2.php:
285:    $meta = new CacheMeta;

// THIS SAMPlE FILE IS NEVER EXECUTED/INCLUDED:
wp-content/plugins/wp-cache/wp-cache-config-sample.php:
24:if (!class_exists('CacheMeta')) {
25:      class CacheMeta  {


wp-content/plugins/wp-cache/wp-cache.php:
554:  $meta = new CacheMeta;

wp-content/wp-cache-config.php:
24:if (!class_exists('CacheMeta')) {
25:      class CacheMeta {


Inside the cache, there are files with serialized objects/classes, here is one sample:

wp-content/cache/wp-cache-9ff82df024f86e4f87d956eb12327694.meta:1:O:9:"cachemeta
":5:{s:7:"dynamic";b:0;s:7:"headers";a:3:{i:0;s:43:"Content-Type: text/html; charset=iso-8859-1";i:1;s:54:"X-Pingback: http://www.XXXXX.de/XXXXX/xmlrpc.ph
p";i:2;s:44:"Last-Modified: Tue, 20 Mar 2007 11:49:15 GMT";}s:3:"uri";s:64:"www.
XXXXX.de/XXXXX/2005/10/31/title-string-here/";s:4:"post";s:2:"14
";s:7:"blog_id";i:1;}


These are the includes and requires of the cache plugin,
a mix of include, reqire and include_once.


 # egrep -ir "include|require" wp-content/plugins/wp-cache/

wp-content/plugins/wp-cache/wp-cache-phase1.php:
if( !@include(ABSPATH . 'wp-content/wp-cache-config.php') ) {

wp-content/plugins/wp-cache/wp-cache-phase1.php:
                        include($cache_file);

wp-content/plugins/wp-cache/wp-cache-phase1.php:
        require(ABSPATH . 'wp-content/plugins/wp-cache/wp-cache-phase2.php');

wp-content/plugins/wp-cache/wp-cache-phase2.php:
   "<!--mclude-->\n<?php include_once('" . ABSPATH . "$1'); ?>\n<!--/mclude-->", $buffer);


wp-content/plugins/wp-cache/wp-cache.php:
if( !@include($wp_cache_config_file) ) {
       @include($wp_cache_config_file_sample);


wp-content/plugins/wp-cache/wp-cache.php:
       require($wp_cache_config_file);


Is this still an APC issue or not? All I can say is 
that this blog works without APC ... 


Regards,
Ulrich
 [2007-03-20 10:01 UTC] rasmus@php.net
I don't understand the logic behind putting the mmap stub on a ramdisk.  I suppose it should work, but it is pretty weird and it certainly doesn't help you in any way since APC will never write to that file.  It's just there as a stub to be unlinked and provide owner-death support to the shared memory segment.
 [2007-03-20 10:02 UTC] gopalv82 at yahoo dot com
You're on php4, right ? Go to apc_main.c function install_class.

- #ifdef ZEND_ENGINE_2    
    /* Special case for mangled names. Mangled names are unique to a file.
     * There is no way two classes with the same mangled name will occur,
     * unless a file is included twice. And if in case, a file is included
     * twice, all mangled name conflicts can be ignored and the class redeclaration
     * error may be deferred till runtime of the corresponding DECLARE_CLASS
     * calls.
     */

    if(cl.name_len != 0 && cl.name[0] == '\0') {
        if(zend_hash_exists(CG(class_table), cl.name, cl.name_len+1)) {
            return SUCCESS;
        }
    }'\0cachemeta/path
+ #ifdef ZEND_ENGINE_2  

I guess php4 has mangled named classes as the '\0cachemeta/path...' showed.
 [2007-03-20 10:15 UTC] gopalv82 at yahoo dot com
Fix is confirmed for a simple c.php 

if(!class_exists('X')) 
{
   class X {};
}

included multiple times.

http://news.php.net/php.pecl.cvs/7503

Read http://t3.dotgnu.info/blog/php/inclusion-checks.html
to understand how exactly APC behaves when it runs into 
such checks - and why include_once lends itself better for
optimisations (more on that in the next releases' INSTALL)
 [2007-03-20 12:06 UTC] pbugs at ausschlafen dot com
Hi again,

@rasmus:
> I don't understand the logic ...

Just the simple logic of a non-programmer. It goes like:
"It's some cache thingy so lets put it on the ram disk."

Whatever APC does to this "stub" - although there was no 
file visible on the ramdisk I saw the size of the available 
space at that mount mount growing and shrinking during 
the test. And APC stopped working as soon as the ramfile was filled and worked (without restart) again when the fillup files were removed. 

@gopalv - thanks for looking into this. The last
patch solved the issue for the Wordpress problem,
so we may close this case.

I will keep the patches you recommended before:
http://news.php.net/php.pecl.cvs/7416
http://news.php.net/php.pecl.cvs/7418
http://news.php.net/php.pecl.cvs/7412
and of course the last one that solved  the redeclare
problem and go live with this patched
version - will that be ok? I hope so.

Thanks again and best regards from
Cologne, Germany,
Ulrich
 [2007-03-21 15:23 UTC] gopalv82 at yahoo dot com
Those four patches should do well enough. 

Secondly, looks like files written to even after unlinking populates the ramdisk. Linux doesn't have a syncer or a MAP_NOSYNC flag, so the data seems to go directly into the disk I/O pages, which for ramdisk is itself.

But ramdisk shouldn't give you any performance boosts as such over mmaping /dev/zero - but problems such as this because of the kernel hitting local ramdisk size will occur, while  mmap(/dev/zero) can scrounge pages from anywhere.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Sep 21 00:01:27 2019 UTC