php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48563 # in php.ini will cause php to crash if latter is running in FastCGI mode
Submitted: 2009-06-15 20:07 UTC Modified: 2009-06-25 01:00 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: dmda at yandex dot ru Assigned: pajoye (profile)
Status: No Feedback Package: Reproducible crash
PHP Version: 5.3.0RC3 OS: Windows XP sp3
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-06-15 20:07 UTC] dmda at yandex dot ru
Description:
------------
A line in php.ini commented with # character will cause php to crash at the following line:
cgi_main.c:686
static void sapi_cgi_log_message(char *message)
{
	TSRMLS_FETCH();

	if (fcgi_is_fastcgi() && CGIG(fcgi_logging)) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

It happens only if PHP is running in FastCGI mode (so fcgi_is_fastcgi() returns true). In this case, any commented lines or any other "deprected" errors will call zend_error handler and subsiquently sapi_cgi_log_message() at the time when CGIG() is not initialized, yet.

Call stack:
sapi_cgi_log_message(char * 0x011a23d8) line 686 + 30 bytes
php_log_err(char * 0x011a23d8, void * * * 0x00332688) line 557 + 10 bytes
php_error_cb(int 8192, const char * 0x10401944 `string', const unsigned int 0, const char * 0x1040bc70 `string', char * 0x00c0c9b4) line 951 + 13 bytes
zend_error(int 8192, const char * 0x1040bc70 `string') line 1020 + 26 bytes
ini_lex(_zval_struct * 0x00c0cadc, void * * * 0x00332688) line 491 + 47 bytes
ini_parse(void * 0x00332688) line 1557 + 16 bytes
zend_parse_ini_file(_zend_file_handle * 0x00c0db58, unsigned char 1, int 0, void (_zval_struct *, _zval_struct *, _zval_struct *, int, void *, void * * *)* 0x100e4874 php_ini_parser_cb(_zval_struct *, _zval_struct *, _zval_struct *, int, _hashtable *), void * 0x105e0de0 configuration_hash, void * * * 0x00332688) line 319 + 9 bytes
php_init_config(void * * * 0x00332688) line 587 + 27 bytes
php_module_startup(_sapi_module_struct * 0x0040b018 cgi_sapi_module, _zend_module_entry * 0x0040b0b0 cgi_module_entry, unsigned int 1) line 1911 + 9 bytes
php_cgi_startup(_sapi_module_struct * 0x0040b018 cgi_sapi_module) line 830 + 17 bytes
main(int 1, char * * 0x00333fa0) line 1573 + 11 bytes
PHP-CGI! mainCRTStartup + 227 bytes



Reproduce code:
---------------
no code/any code

Expected result:
----------------
no crash

Actual result:
--------------
access violation

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-16 23:40 UTC] pajoye@php.net
I can't reproduce it, can you try using the RC4 or cvs snapshot please?
 [2009-06-16 23:45 UTC] dmda at yandex dot ru
>I can't reproduce it

You can't repoduce it unless you use FASTCGI mode.
Try for example with IIS/FastCGI or any other FastCGI runner.

>can you try using the RC4 

I thought RC4 is not available. www.php.net still shows RC3.
Where can I find RC4?
 [2009-06-16 23:48 UTC] pajoye@php.net
I meant RC3 :)

I do use fastcgi, with IIS7. The VC9-x86 build.
 [2009-06-16 23:51 UTC] pajoye@php.net
Can you send me a zip (or a link to it) with the php.ini causing the crash? Maybe it is not the comment but some hidden chars.
 [2009-06-17 00:05 UTC] dmda at yandex dot ru
php.ini, just one line:

#extension_dir=./

screenshot: http://www.image123.net/9bclxbny3f1fpic.html
 [2009-06-17 00:10 UTC] pajoye@php.net
Looks like VC6, I'd to try it again.

Thanks for the feedback
 [2009-06-17 08:03 UTC] pajoye@php.net
btw, for what I can read in the screenshot, you are executing the php.ini :) Is it really what you want?
 [2009-06-17 08:27 UTC] RQuadling at GMail dot com
Hi.

Using Windows Server 2008 Enterprise with IIS7 (V7.0.6000.16386) with PHP V5.3.0RC4-dev 
(Build date Jun 16 2009 08:56:09, Compiler MSVC9 (Visual C++ 2008) x86) with Server API CGI/FastCGI (Is that enough detail?).

Using 

#extension_dir = C:/PHP5/ext
and
extension_dir = C:/PHP5/ext

(restarting IIS in between each change).

No problems.

Sure extensions aren't available (as seen in phpinfo()). With the # I have 34 
extensions loaded (count(get_loaded_extensions()) vs 58 without the # (just loaded them 
all that I could as a test).

No other change to the INI file.
 [2009-06-17 08:38 UTC] dmda at yandex dot ru
>btw, for what I can read in the screenshot, you are executing the
>php.ini :) Is it really what you want?

No, I'm not that idiot, and even if I did this, wouldn't php just ignore the file as it contains no php code?
May I ask why you think I'm executing php.ini?

From the screenshot it's clear that the error message refers to php.ini. Do you have the same error message in php.log? 


>(restarting IIS in between each change).

Did you make sure that no php-cgi.exe processes remained running?
Did you make sure that browser gets the content from executed script and IIS returned HTTP/200?
 [2009-06-17 09:13 UTC] pajoye@php.net
On the screenshot, bottom right: 
"PHP Deprecated: Comments starting with '#' are deprecated in  ..php.ini..."

That can happen only when php-cgi.exe php.ini is used.

Please try "php -c php.ini -i", and no, I do not consider you as an idiot (just in case :)
 [2009-06-17 10:01 UTC] dmda at yandex dot ru
>On the screenshot, bottom right: 
>"PHP Deprecated: Comments starting with '#' are deprecated in 
>..php.ini..."
>
>That can happen only when php-cgi.exe php.ini is used

Funny :), but you're absolutely wrong here. Please check callstack that I submitted in the original post and you'll see that php was PARSING that php.ini file when it tried to throw an error and crashed. 

FYI php parses ini files too and there are lexer/grammars in 
Zend/zend_ini_parser.y and Zend/zend_ini_scanner.l

In fact php was run with a pure php file, but it does not matter because php did not even start compiling that file.
 [2009-06-17 11:44 UTC] dmda at yandex dot ru
IIS crashes with this error:
============================================

FastCGI Error
The FastCGI Handler was unable to process the request. 
--------------------------------------------------------------------------------

Error Details:

The FastCGI process exited unexpectedly 
Error Number: -1073741819 (0xc0000005). 
Error Description: Unknown Error 
HTTP Error 500 - Server Error.
Internet Information Services (IIS)

============================================
if you have VC6's JIT debugger turned on, you'll be prompted to start debugging.

NOTE0:
Installed IIS6 is the one that came with XP. FastCGI is taken from http://php.iis.net/

NOTE1:
Don't restart IIS using its own restart function. This function won't unload php-cgi.exe processes, so they may not see changes in php.ini. Restart "World Wide Web Publishing" service, and make sure php-cgi.exe is not listed in the process list, otherwise kill it.

NOTE2:
Official php-5.3RC3 binary http://windows.php.net/qa/
VC6 x86 Thread Safe (2009-Jun-10 21:10:42) Zip [12.83MB]
sha1: f657b41f9035d0d2245a83bbdf65c5ce0767245a 
is crashing too.

NOTE3:
php.ini should contain a line commented with # terminated with EOL (either 0xD,0xA, or just 0xA)
for example:
========================
#somethign

========================

NOTE4:
what you try to run does not matter. For example you may want to try
<?php phpinfo(); ?>


Let know if you need any furhter info.
 [2009-06-17 13:07 UTC] pajoye@php.net
Quick note: If you use fastcgi, you don't need thread safe build, use NTS. And for php 5.3, use VC9 NTS builds, even faster/better.
 [2009-06-17 13:38 UTC] dmda at yandex dot ru
yes, I know this and pointed to this fact in PHPCON 2003.

Anyway the trouble manifests itself.
As far as I understand, the problem is with initialization of the module context. It is not done at the moment when php core logs the error in php.ini ("deprecated stuff" in this case).
If I'm correct, initialization is initialization. NTS won't crash just because it does not allocate its context in the heap because it uses static data. Even if it works foryou, uninitialized data won't let you control the values. You either can not get the error in php's log or can't stop it from appearing.
Try to change fcgi_logging value (fastcgi.logging = ON and OFF) and see if the error appears or does not appear respectively.
 [2009-06-17 13:53 UTC] pajoye@php.net
I still do not undestand how you get this warning as it happens only when php is trying to compile a php src file, and not a php.ini.

I'd to try with fcgi TS and see if it crashes. However, I'd to say that it is not a stopping for 5.3 if it does. FCGI should not be used using the TS builds but NTS.


 [2009-06-17 14:29 UTC] dmda at yandex dot ru
> I still do not undestand how you get this warning as it happens 
> onlywhen php is trying to compile a php src file, and not 
> a php.ini.

Sorry, seems you ignore all I posted :)
Php was initializing itself. It pefroms this initialization and reading/parsing php.ini everytime BEFORE running any php src files.
Please don't try to "understand", either learn code or ask experienced people :)

> I'd to try with fcgi TS and see if it crashes. However, I'd to say > that it is not a stopping for 5.3 if it does. 

I think it's up to PM.

> FCGI should not be used using the TS builds but NTS.

Really? Only because TS is sligtly slower? or what?
Did you manage to run NTS/VC9 build at all?
I does not work for me.
TS/VC6 works if there are # in php.ini. NTS/VC9 produces HTTP/500 and nothing else. I'll report this separately.
 [2009-06-17 14:30 UTC] dmda at yandex dot ru
TS/VC6 works if there are # in php.ini
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I meant
TS/VC6 works if there is no # in php.ini
 [2009-06-17 14:52 UTC] pajoye@php.net
"Really? Only because TS is sligtly slower? or what?
Did you manage to run NTS/VC9 build at all? I does not work for me."

Yes, it works for me and almost the full IIS team as well.

"NTS/VC9 produces HTTP/500 and nothing else. I'll report this separately."

Be sure that you have the VC9 runtime installed. Best is to test it in cli first.
 [2009-06-17 15:07 UTC] dmda at yandex dot ru
Thanks for notes :)
I'll report as soon as I find a way to reproduce the problem.
Quite unexpectedly VC9/NTS started working :)

Regarding VC6/TS | VC9/TS, did you manage to reproduce the crash?
 [2009-06-17 18:59 UTC] pajoye@php.net
Cannot reproduce it using the VC6/TS or VC9/TS.

Does it crash for you using php-cgi.exe -c php.ini -i?
 [2009-06-25 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".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 09:01:27 2024 UTC