APC issue on solaris gcc-4.0.2 & 2.95.2

From: Date: Fri, 09 Jun 2006 22:34:56 +0000
Subject: APC issue on solaris gcc-4.0.2 & 2.95.2
Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-3872@lists.php.net to get a copy of this message
So, after a bit of chasing my tail I think I may have found a bit of a bug in APC. It looks like there is an alignment problem in apc_sma.c In version 3.0.8 the header_t struct was 8 byte aligned. In cvs there were some members added to that struct and now it is 12byte aligned. You start allocating immediately after header_t so things are allocated on a 4 byte boundary and not 8 as you should. To make my life easy I added this small patch which by no means is the correct way to fix the problem, but it was easy :) and appears to work. I believe the real fix is a bit more involved. % cvs diff -c apc_sma.c Index: apc_sma.c =================================================================== RCS file: /repository/pecl/apc/apc_sma.c,v retrieving revision 1.52 diff -c -r1.52 apc_sma.c
*** apc_sma.c   17 May 2006 16:31:14 -0000      1.52
--- apc_sma.c 9 Jun 2006 22:00:52 -0000 *************** *** 63,68 **** --- 63,69 ---- #if ALLOC_DISTRIBUTION
     size_t adist[30];
#endif
+     size_t pad1; /* temp fix to make sturck align divisible by 8 */
}; Here is the crash i was getting and some debug info. Let me know if there is anything else you need for debugging... -James (gdb) run -b 127.0.0.1:9968 -c ../lib/php/phpd.ini Starting program: /user/jluedke/local/src/phpd_build/local/bin/php -b 127.0.0.1:9968 -c ../lib/php/phpd.ini Program received signal SIGSEGV, Segmentation fault. 0xff0cae60 in my_copy_znode (dst=0xfd00237c, src=0x291878, allocate=0xff0d58c0 <apc_sma_malloc>, deallocate=0xff0d5d50 <apc_sma_free>) at /user/jluedke/local/src/phpd_build/APC-cvs/apc/apc_compile.c:334
334         memcpy(dst, src, sizeof(src[0]));
(gdb) up #1 0xff0caf44 in my_copy_zend_op (dst=0xfd002374, src=0x291870, allocate=0xff0d58c0 <apc_sma_malloc>, deallocate=0xff0d5d50 <apc_sma_free>) at /user/jluedke/local/src/phpd_build/APC-cvs/apc/apc_compile.c:367
367         if( my_copy_znode(&dst->result, &src->result, allocate, deallocate) == NULL
(gdb) up #2 0xff0cc240 in apc_copy_op_array (dst=0xfd0022cc, src=0x28b5f8, allocate=0xff0d58c0 <apc_sma_malloc>, deallocate=0xff0d5d50 <apc_sma_free>) at /user/jluedke/local/src/phpd_build/APC-cvs/apc/apc_compile.c:1141
1141            if(!(my_copy_zend_op(dst->opcodes+i, src->opcodes+i, allocate, deallocate))) {
(gdb) print dst $1 = (zend_op_array *) 0xfd0022cc (gdb) print ((unsigned int)dst)%8
$2 = 4                                                                  <---- ikes !!!!
(gdb) p ((unsigned int)src)%8 $3 = 0 (gdb)

« previous php.pecl.dev (#3872) next »