|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35926 Strange configuration behavior, gdb reports corrupt stack
Submitted: 2006-01-07 22:41 UTC Modified: 2006-01-15 01:00 UTC
From: jeff95350 at yahoo dot com Assigned:
Status: No Feedback Package: PHP options/info functions
PHP Version: 4.4.1 OS: FreeBSD 5.4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: jeff95350 at yahoo dot com
New email:
PHP Version: OS:


 [2006-01-07 22:41 UTC] jeff95350 at yahoo dot com
PHP 4.4.1 seems to behave strangely when looking for the config file. Below I have an example that appears to be contradictory, or at least extremely unintuitive. PHP reports that it is using a certain configuration file, but then ignores the contents. When I specify the configuration file directly, it works fine.

While investigating, I also show GDB reporting a corrupted stack.

Reproduce code:
$ pwd
$ rm -rf php-4.4.1/
$ tar jxf ../download/php-4.4.1.tar.bz2 
$ cd php-4.4.1/
$ ./configure --prefix=/usr/local/admin --with-config-file-path=/usr/local/admin/etc/php.ini --with-config-file-scan-dir=/usr/local/admin/etc/php --with-pgsql --with-mysql --with-curl --with-gd --enable-fastcgi --with-openssl --with-zlib --enable-bcmath --with-bz2 --enable-calendar --enable-dba --with-db4 --with-mhash --with-mcrypt 
$ make && make install
$ grep pgsql.allow_persistent /usr/local/admin/etc/php.ini
pgsql.allow_persistent = Off
$ /usr/local/admin/bin/php -i | grep Configuration
<tr><td class="e">Configuration File (php.ini) Path </td><td class="v">/usr/local/admin/etc/php.ini </td></tr>

Notice that php reports that it is using the config file "/usr/local/admin/etc/php.ini", and that that config file has pgsql.allow_persistent = Off.

Expected result:
$ /usr/local/admin/bin/php -i | grep pgsql.allow_persistent
<tr><td class="e">pgsql.allow_persistent</td><td class="v">Off</td><td class="v">Off</td></tr>
$ /usr/local/admin/bin/php -i \
    -c /usr/local/admin/etc/php.ini \
    | grep pgsql.allow_persistent
<tr><td class="e">pgsql.allow_persistent</td><td class="v">Off</td><td class="v">Off</td></tr>

Actual result:
Notice below how pgsql.allow_persistent is On when the config file says it should be Off.

$ /usr/local/admin/bin/php -i | grep pgsql.allow_persistent
<tr><td class="e">pgsql.allow_persistent</td><td class="v">On</td><td class="v">On</td></tr>

Notice below how the config file obviously works. It's really just the php.ini-dist with all of the "allow_persistent" settings turned Off. Below I specify the config file explicitly and it works fine.

$ /usr/local/admin/bin/php -i \
    -c /usr/local/admin/etc/php.ini \
    | grep pgsql.allow_persistent
<tr><td class="e">pgsql.allow_persistent</td><td class="v">Off</td><td class="v">Off</td></tr>

While investigating the problem, I saw some strange results from gdb:

$ gdb /usr/local/admin/bin/php
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...
(gdb) set args "-i"
(gdb) break php_init_config
Breakpoint 1 at 0x81468b8: file /home/admin/install/php-4.4.1/main/php_ini.c, line 251.
(gdb) run
Starting program: /usr/local/admin/bin/php "-i"

Breakpoint 1, php_init_config ()
    at /home/admin/install/php-4.4.1/main/php_ini.c:251
251             zend_file_handle fh = {0};
(gdb) watch free_ini_search_path
Hardware watchpoint 2: free_ini_search_path
(gdb) continue
Hardware watchpoint 2: free_ini_search_path

Old value = 0
New value = 1
php_init_config () at /home/admin/install/php-4.4.1/main/php_ini.c:288
288                     php_ini_search_path[0] = 0;
(gdb) step
295                     if (env_location[0]) {
315                     if (strcmp(, "cli") != 0) {
316                             if (*php_ini_search_path) {
319                             strcat(php_ini_search_path, ".");
331                     if (sapi_module.executable_location) {
332                             binary_location = estrdup(sapi_module.executable_location);
_estrdup (s=0x81bed31 "i-fcgi")
    at /home/admin/install/php-4.4.1/Zend/zend_alloc.c:360
360     {
(gdb) finish
Run till exit from #0  _estrdup (s=0x81bed31 "i-fcgi")
    at /home/admin/install/php-4.4.1/Zend/zend_alloc.c:360
0x08146e94 in php_init_config ()
    at /home/admin/install/php-4.4.1/main/php_ini.c:332
332                             binary_location = estrdup(sapi_module.executable_location);
Value returned is $1 = 0x822304c "/usr/local/admin/bin/php"
(gdb) step
337                     if (binary_location) {
332                             binary_location = estrdup(sapi_module.executable_location);
337                     if (binary_location) {
338                             char *separator_location = strrchr(binary_location, DEFAULT_SLASH);
Error evaluating expression for watchpoint 2
Previous frame identical to this frame (corrupt stack?)
Watchpoint 2 deleted.
0x281c7b07 in r_debug_state () from /libexec/

It looks like there's some kind of problem there, since gdb says "corrupt stack". I'm not particularly good with gdb, so maybe there's nothing wrong with PHP.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-07 22:56 UTC]
Please try using this CVS snapshot:
For Windows:

 [2006-01-15 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2006-06-21 14:34 UTC] php-bug-35926 at ryandesign dot com
For --with-config-file-path, you have specified the path to 
the php.ini file, but ./configure --help explains that you 
must specify the path to the *directory* in which php.ini can 
be found.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 17:01:29 2024 UTC