apache2handler/SIGSEGV with apache2 (prefork)

php.internals

Oliver Block

19 years ago
Hello, I am getting a SIGSEGV when compiling php-5.2.2. gdb breaks up at the if statement of the following function static void php_apache_add_version(apr_pool_t *p) { TSRMLS_FETCH(); if (PG(expose_php)) { ap_add_version_component(p, "PHP/" PHP_VERSION); } } It only occurs when --enable-maintainer-zts is used. main/php_globals.h: # define PG(v) TSRMG(core_globals_id, php_core_globals *, v) extern PHPAPI int core_globals_id; #else # define PG(v) (core_globals.v) extern ZEND_API struct _php_core_globals core_globals; #endif TSRM/TSRM.h #define TSRM_UNSHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)-1) #define TSRMG(id, type, element) (((type) (*((void ***) tsrm_ls)) [TSRM_UNSHUFFLE_RSRC_ID(id)])->element) GDB tells me that core_globals_id == 0 which leads to an index of -1 -- if I interpret the results correctly. Best Regards, Oliver

Antony Dovgal

19 years ago
On 05/08/2007 05:36 AM, Oliver Block wrote:
> Hello, > > I am getting a SIGSEGV when compiling php-5.2.2. > > gdb breaks up at the if statement of the following function > > static void php_apache_add_version(apr_pool_t *p) > { > TSRMLS_FETCH(); > if (PG(expose_php)) { > ap_add_version_component(p, "PHP/" PHP_VERSION); > } > } > > It only occurs when --enable-maintainer-zts is used. > > main/php_globals.h: > # define PG(v) TSRMG(core_globals_id, php_core_globals *, v) > extern PHPAPI int core_globals_id; > #else > # define PG(v) (core_globals.v) > extern ZEND_API struct _php_core_globals core_globals; > #endif > > TSRM/TSRM.h > #define TSRM_UNSHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)-1) > #define TSRMG(id, type, element) (((type) (*((void ***) tsrm_ls)) > [TSRM_UNSHUFFLE_RSRC_ID(id)])->element) > > GDB tells me that core_globals_id == 0 which leads to an index of -1 -- if I > interpret the results correctly.
Either GDB is wrong or your build is badly broken. core_globals_id is initialized in main/main.c, line 1491 *rsrc_id = TSRM_SHUFFLE_RSRC_ID(id_count++); #define TSRM_SHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)+1)
-- Wbr, Antony Dovgal

Oliver Block

19 years ago
Hello Tony, according to my backtrace, this line (main/main.c:1491) is not processed. 366 if (PG(expose_php)) { (gdb) p core_globals_id $4 = 0 The backtrace follows: Program received signal SIGSEGV, Segmentation fault. 0x40bb4449 in php_apache_add_version (p=0x80a40a8) at /usr/local/src/php-5.2.2/sapi/apache2handler/sapi_apache2.c:366 366 if (PG(expose_php)) { (gdb) bt full #0 0x40bb4449 in php_apache_add_version (p=0x80a40a8) at /usr/local/src/php-5.2.2/sapi/apache2handler/sapi_apache2.c:366 tsrm_ls = (void ***) 0x83a19b0 #1 0x40bb4537 in php_apache_server_startup (pconf=0x80a40a8, plog=0x80ce150, ptemp=0x80d0158, s=0x80be308) at /usr/local/src/php-5.2.2/sapi/apache2handler/sapi_apache2.c:417 data = (void *) 0x1 userdata_key = 0x40c704e7 "apache2hook_post_config" #2 0x080691fd in ap_run_post_config () No symbol table info available. #3 0x0806f622 in main () No symbol table info available. Regards, Oliver Am Dienstag, 8. Mai 2007 10:21 schrieben Sie:

Antony Dovgal

19 years ago
On 05/08/2007 01:51 PM, Oliver Block wrote:
> Hello Tony, > > according to my backtrace, this line (main/main.c:1491) is not processed.
How to reproduce it?
> 366 if (PG(expose_php)) { > (gdb) p core_globals_id > $4 = 0 > > The backtrace follows: > > Program received signal SIGSEGV, Segmentation fault. > 0x40bb4449 in php_apache_add_version (p=0x80a40a8) > at /usr/local/src/php-5.2.2/sapi/apache2handler/sapi_apache2.c:366 > 366 if (PG(expose_php)) { > (gdb) bt full > #0 0x40bb4449 in php_apache_add_version (p=0x80a40a8) > at /usr/local/src/php-5.2.2/sapi/apache2handler/sapi_apache2.c:366 > tsrm_ls = (void ***) 0x83a19b0 > #1 0x40bb4537 in php_apache_server_startup (pconf=0x80a40a8, plog=0x80ce150, > ptemp=0x80d0158, s=0x80be308) > at /usr/local/src/php-5.2.2/sapi/apache2handler/sapi_apache2.c:417 > data = (void *) 0x1 > userdata_key = 0x40c704e7 "apache2hook_post_config" > #2 0x080691fd in ap_run_post_config () > No symbol table info available. > #3 0x0806f622 in main () > No symbol table info available.
-- Wbr, Antony Dovgal

Oliver Block

19 years ago
Am Dienstag, 8. Mai 2007 11:55 schrieben Sie:
> On 05/08/2007 01:51 PM, Oliver Block wrote: > > Hello Tony, > > > > according to my backtrace, this line (main/main.c:1491) is not processed. > > How to reproduce it?
I just compiled the latest php 5 release with zts. I am working on a V-Server with Plesk running SuSE 9.3 (apache 2.0.53. I will search the swsoft website for additional information on compiling php5. Maybe I need to do some additional changes. Regards, Oliver

Antony Dovgal

19 years ago
On 05/08/2007 03:27 PM, Oliver Block wrote:
> Am Dienstag, 8. Mai 2007 11:55 schrieben Sie: >> On 05/08/2007 01:51 PM, Oliver Block wrote: >> > Hello Tony, >> > >> > according to my backtrace, this line (main/main.c:1491) is not processed. >> >> How to reproduce it? > > I just compiled the latest php 5 release with zts. I am working on a V-Server > with Plesk running SuSE 9.3 (apache 2.0.53.
What was your configure line?
> I will search the swsoft website for additional information on compiling php5. > Maybe I need to do some additional changes.
-- Wbr, Antony Dovgal

Oliver Block

19 years ago
Am Dienstag, 8. Mai 2007 13:45 schrieben Sie:
> What was your configure line?
./configure --with-apxs2=/usr/sbin/apxs2 --prefix=/usr/local/php5 --enable-debug --enable-maintainer-zts --with-mysql --with-imap --with-imap-ssl There was a php4 rpm which was installed by the SuSE setup tool (YaST). After removing it, the server started without problems. So this segmentation fault seems to occur, when there are both versions, php4 and php5, installed. Regards, Oliver

Antony Dovgal

19 years ago
On 05/08/2007 04:02 PM, Oliver Block wrote:
> Am Dienstag, 8. Mai 2007 13:45 schrieben Sie: >> What was your configure line? > > ./configure --with-apxs2=/usr/sbin/apxs2 --prefix=/usr/local/php5 > --enable-debug --enable-maintainer-zts --with-mysql --with-imap > --with-imap-ssl > > There was a php4 rpm which was installed by the SuSE setup tool (YaST). > > After removing it, the server started without problems. So this segmentation > fault seems to occur, when there are both versions, php4 and php5, installed.
Ah, so you're compiling a threadsafe PHP to use with a non-threadsafe Apache and loading both PHP4 and PHP5 in the same time. This looks like a total misconfiguration.
-- Wbr, Antony Dovgal

Oliver Block

19 years ago
Am Dienstag, 8. Mai 2007 14:12 schrieben Sie:
> Ah, so you're compiling a threadsafe PHP to use with a non-threadsafe > Apache and loading both PHP4 and PHP5 in the same time. This looks like a > total misconfiguration.
That's right. It was obviously misconfigured! I see no connection to threadsafety php vs. non-threadsafety apache though. Regards, Oliver

William A. Rowe, Jr.

19 years ago
Antony Dovgal wrote:
> On 05/08/2007 04:02 PM, Oliver Block wrote: >> Am Dienstag, 8. Mai 2007 13:45 schrieben Sie: >>> What was your configure line? >> >> ./configure --with-apxs2=/usr/sbin/apxs2 --prefix=/usr/local/php5 >> --enable-debug --enable-maintainer-zts --with-mysql --with-imap >> --with-imap-ssl >> >> There was a php4 rpm which was installed by the SuSE setup tool (YaST). >> >> After removing it, the server started without problems. So this >> segmentation fault seems to occur, when there are both versions, php4 >> and php5, installed. > > Ah, so you're compiling a threadsafe PHP to use with a non-threadsafe > Apache and loading both PHP4 and PHP5 in the same time. > This looks like a total misconfiguration.
What non-threadsafe Apache? There are few such Apache 2 beasts. If apr was installed separately it's almost always going to pick up threads by default, and since these are YaST packages I'm betting dollars to donuts that apr comes from it's own rpm. Apache2 itself would therefore be threadsafe compiled against that apr. I'm gambling that PHP4 was non-zts and PHP5 was zts, resulting in mass confusion.