Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 324073 - Reading system-wide php.ini by PHP execs leads to segfaults
Summary: Reading system-wide php.ini by PHP execs leads to segfaults
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: PDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: PHP Debug CLA
QA Contact: Ilina Stefanova CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-31 06:50 EDT by Jacek Pospychala CLA
Modified: 2020-05-14 11:24 EDT (History)
7 users (show)

See Also:
ganoro: review+
jacek.pospychala: review?
zhaozhongwei: review+


Attachments
patch (1.93 KB, patch)
2010-08-31 06:51 EDT, Jacek Pospychala CLA
no flags Details | Diff
patch v2 (2.84 KB, patch)
2010-09-02 10:20 EDT, Jacek Pospychala CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jacek Pospychala CLA 2010-08-31 06:50:13 EDT
When testing available PHPExecs for their capabilities, each exe is invoked with following command line:

/full/path/to/php.exe -c /tmp/zend_debug/tmpdir -v

/tmp/zend_debug/tmpdir contains php.ini which is an empty file.

Unfortunately this still leads php.exe to read system-wide php.ini. In some cases this leads to segfaults. In particular in php-cgi.exe 5.3.1 after installing Zend Server.


The correct command line should use -n option as well:

/full/path/to/php.exe -n -c /tmp/zend_debug/tmpdir -v

In this case, only php.in from /tmp/zend_debug/tmpdir is read and there's no segfault anymore.
Comment 1 Jacek Pospychala CLA 2010-08-31 06:51:03 EDT
Created attachment 177822 [details]
patch

use -n in all invokations of php execs
Comment 2 Jacek Pospychala CLA 2010-09-01 04:04:43 EDT
Comment on attachment 177822 [details]
patch

after further discussion with Roy, this solution turns incorrect. It would end up not reading any php.ini, whereas we want only ours php.ini to be read. But for some reason some other config is also loaded #$#(*( :-)
Comment 3 Jacek Pospychala CLA 2010-09-02 10:20:44 EDT
Created attachment 178045 [details]
patch v2

after even more discussions, it appears that -n is a correct argument.
To sum up:
php-cgi -c /dir/to/my/php.ini -n    - reads only /dir/to/my/php.ini config
php-cgi -c /dir/to/my/php.ini       - reads both my php.ini and system wide cfg
php-cgi -n                          - reads no any config
php-cgi                             - reads system wide cfg

system wide cfg may be <somewhere>/etc/php.ini as well as <somewhere/etc/conf.d/*
Comment 4 Jacek Pospychala CLA 2010-09-02 10:52:58 EDT
fixed in head and branch
Comment 5 Martin Carpentier CLA 2011-02-22 11:41:26 EST
I recently had to update my Eclipse PDT to the latest milestone (because of the "broken file compare" bug) and found out that I couldn't run nor debug PHP script anymore because only the main php.ini file is loaded.
All the extra configurations defined in /etc/php5/cli/conf.d/*.ini are ignored.

After many searches for a solution I stumbled upon this bug report and was a bit mystified by the fix used.

I can see how it's not a problem on a windows platform where all the php configuration is usually defined in one single ini file but on a Linux platform, modules configuration are set in external ini files (which aren't loaded anymore when debugging).

I tried merging all the configurations in one single file and set the PHP executable to use it (in Preferences -> PHP -> PHP Executables) but it doesn't work.
The php.ini file in /tmp/zend_debug/session*.tmp is always ends up as a copy of the original /etc/php5/cli/php.ini file.

Are you sure this is the proper and only solution for the segfault problem?
Comment 6 Mike Pav CLA 2011-03-08 16:03:29 EST
I have the same issue as comment #5.  On Linux (Ubuntu) specifically, PHP uses a conf.d directory where all of the extension ini files are managed (things like mysql, xdebug, ...).  The fix in this bug disables the ability to scan a dir for additional .ini files.
Comment 7 Jacek Pospychala CLA 2011-03-09 06:48:17 EST
hi,
the point of this bug was that sometimes users have more than version of php executable which are incompatbile with each other. So now when one version of php exe was reading system-wide preferences of another executable, it was trying to load incompatible modules and was crashing with segfault.

When configuring php executable in preferences, can you specify the optional php.ini file?
Comment 8 Mike Pav CLA 2011-03-09 10:47:16 EST
It is not a single optional php.ini file.  There is the standard php.ini file that we all know and love, then there is a conf.d directory that contains config info for all the optional PHP modules.  Martin described this in comment #5.  The point is that when you specify the -c or -n args to PHP, it does not read from the conf.d directory, even if you have set the PHP_INI_SCAN_DIR env var.

The workaround that I'm using is to concatenate all the .ini files in the conf.d and append them to the root php.ini file.
Comment 9 Jacek Pospychala CLA 2011-03-10 02:50:31 EST
ok, so we probably should add an option (a checkbox?) like "Use system default php.ini configuration". So you could allow or deny reading php.ini and conf.d from Exes preferences. 
Alternatively we could expose ability to customize command line parameters. So you'd manually add/remove "-n -c"

Would that work for you?
Comment 10 Mike Pav CLA 2011-03-10 11:05:19 EST
I would love the "Use system default php.ini configuration" option.
Comment 11 Jacek Pospychala CLA 2011-03-10 11:14:37 EST
opened new bug #339547 for fixing this.
Comment 12 Jacek Pospychala CLA 2011-03-10 11:15:01 EST
Thanks for rising this issue guys!
Comment 13 Kalin CLA 2011-08-03 08:37:20 EDT
Closing...