php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56573 XtOffsetOf not defined in apache
Submitted: 2005-10-03 00:08 UTC Modified: 2006-03-11 04:43 UTC
From: undefined at pobox dot com Assigned:
Status: Not a bug Package: APC (PECL)
PHP Version: 4.3.10 OS: Debian GNU/Linux 3.1 "Sarge"
Private report: No CVE-ID: None
 [2005-10-03 00:08 UTC] undefined at pobox dot com
Description:
------------
in php_apc.c & apc_main.c XtOffsetOf is undefined before including httpd.h, but in apr_general.h apache defines APR_XtOffsetOf as APR_OFFSETOF, but not XtOffsetOf.

i presume apache at one time had XtOffsetOf defined, necessitating undefining XtOffsetOf or encountering redefinition errors/warnings, but recently apache (or maybe just debian) appended APR to avoid name clashes (like with php).

on a sidenote: i compiled by hand (both optimizations) & with the pear default (apxs optimization only), and with apc's default configuration, apxs-only is faster.

ab2 -n 100 http://localhost/squirrelmail/src/login.php
apxs only: 0.490800 seconds
both: 0.587754 seconds
no apc: 1.911156 seconds


Reproduce code:
---------------
diff -urp APC-3.0.8.orig/apc_main.c APC-3.0.8/apc_main.c
--- APC-3.0.8.orig/apc_main.c	2005-08-16 14:54:08.000000000 -0500
+++ APC-3.0.8/apc_main.c	2005-10-02 17:52:56.874884446 -0500
@@ -43,7 +43,6 @@
 #if PHP_API_VERSION <= 20020918
 #if HAVE_APACHE
 #ifdef APC_PHP4_STAT
-#undef XtOffsetOf
 #include "httpd.h"
 #endif
 #endif
diff -urp APC-3.0.8.orig/php_apc.c APC-3.0.8/php_apc.c
--- APC-3.0.8.orig/php_apc.c	2005-08-19 04:16:56.000000000 -0500
+++ APC-3.0.8/php_apc.c	2005-10-02 17:53:03.005941653 -0500
@@ -41,7 +41,6 @@
 #if PHP_API_VERSION <= 20020918
 #if HAVE_APACHE
 #ifdef APC_PHP4_STAT
-#undef XtOffsetOf
 #include "httpd.h"
 #endif
 #endif

Actual result:
--------------
apache2-prefork-dev 2.0.54-5
libapr0-dev 2.0.54-5
php4-dev 4.3.10-16

$ pear download APC
$ tar -xzf APC-3.0.8.tgz
$ cd APC-3.0.8
$ phpize
Configuring for:
PHP Api Version:         20020918
Zend Module Api No:      20020429
Zend Extension Api No:   20021010
$ export CPPFLAGS="-I/usr/include/apache2 -I/usr/include/apr-0 -DAPC_PHP4_STAT"
$ ./configure --enable-apc --enable-apc-mmap --with-apxs=$(which apxs2)
...
$ make
...
php_apc.c:136: warning: implicit declaration of function `XtOffsetOf'               
php_apc.c:136: error: syntax error before "zend_apc_globals"
php_apc.c:136: error: initializer element is not constant
php_apc.c:136: error: (near initialization for `ini_entries[0].mh_arg1')            
php_apc.c:136: error: initializer element is not constant
php_apc.c:136: error: (near initialization for `ini_entries[0]')
<continued for php_apc.c lines 137-154>


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-03 00:52 UTC] rasmus@php.net
Most people still use Apache1 and this is a problem there.  Feel free to submit a patch that makes it work on both.
 [2005-10-03 01:15 UTC] undefined at pobox dot com
the patch would be a simple one if there was some define based on apache's version (APACHE2 or APACHE_VERSION >= 2).  my ignorance of apache is showing here.

i'm not too motivated to submit a more proper patch (beyond my already submitted hack) as my initial benchmarking reveals that the extra optimization makes apc slower.  though i would love to be proven wrong.

my real motivation in submitting this bug report was not to garner a fix (my hack works for those that need it), but for saving anyone that might experience the same bug an hour or two familiarizing themselves with the apc, php, & apache2 source code.
 [2005-10-03 01:41 UTC] rasmus@php.net
Using ab for a split second is not a benchmark.  What you get from that is pretty much random.  And I have no idea what you are talking about anyway.  Using apxs cannot possibly make it go slower.  At worst it didn't pick up the right includes and couldn't eliminate the syscall.  If it does make it go slower it is either because your benchmark was crap or the compiler switches in your apxs script are sub-optimal which also means that your Apache is running slower than it should be since it was likely compiled with those.
 [2006-03-11 04:43 UTC] rasmus@php.net
no real bug here
 [2006-03-24 17:05 UTC] php dot net at vanbragt dot com
This really is an issue. I tried compiling APC on Debian Sarge (only stable packages) with APC 3.0.10, PHP 4.3.10-15 (deb package) and Apache 2.0.54-4 (deb package) on amd64 and I got the same messages as undefined. His patch seems to fix it for me without it APC doesn't compile. 

The performance issue that he mentions is a separate issue.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 11 00:01:28 2024 UTC