php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65500 debug_backtrace doesn't identify file name when config contains invalid comment
Submitted: 2013-08-22 08:30 UTC Modified: 2021-08-31 13:43 UTC
From: alina dot sch61 at gmail dot com Assigned:
Status: Analyzed Package: FPM related
PHP Version: 5.4 or later OS: any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: alina dot sch61 at gmail dot com
New email:
PHP Version: OS:

 

 [2013-08-22 08:30 UTC] alina dot sch61 at gmail dot com
Description:
------------
If php-fpm.conf contains not correctly commented string (commented with "#" 
symbol instead of semicolon), debug_backtrace() function 
doesn't return in message name of file and line where this mistake was done:

[args] => Array(
  [0] => ErrorException Object(
     [message:protected] => Comments starting with '#' are deprecated in Unknown 
on line 1
     [string:Exception:private] =>
     [code:protected] => 8192
     [file:protected] => Unknown
     [line:protected] => 0
     [trace:Exception:private] => Array(
           [0] => Array(
                  [function] => shutdownHandler
                  [class] => Shared\Error\ErrorHandler
                  [type] => ->
                  [args] => Array()
           )
     )
     [previous:Exception:private] =>
     [severity:protected] => 0
  )
)

But if such comment is made in config of one of the extensions (e.g. mysql.ini) 
name of file will be successfully identified for message.

[args] => Array(
  [0] => ErrorException Object(
       [message:protected] => Comments starting with '#' are deprecated in 
/etc/php5/fpm/conf.d/20-mysql.ini on line 2
       [string:Exception:private] =>
       [code:protected] => 8192
       [file:protected] => Unknown
       [line:protected] => 0
       [trace:Exception:private] => Array(
           [0] => Array(
               [function] => shutdownHandler
               [class] => Shared\Error\ErrorHandler
               [type] => ->
               [args] => Array()
           )
        )
        [previous:Exception:private] =>
        [severity:protected] => 0
    )
)



Expected result:
----------------
If not correct comment is in php-fpm.conf message doesn't contain file name:

[message:protected] => Comments starting with '#' are deprecated in 
/etc/php5/fpm/php-fpm.conf on line 7

Actual result:
--------------
If not correct comment is in php-fpm.conf message doesn't contain file name:

[message:protected] => Comments starting with '#' are deprecated in Unknown on 
line 1 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-08-22 10:38 UTC] yohgaki@php.net
-Status: Open +Status: Analyzed -Package: FPM related +Package: Scripting Engine problem -Operating System: Linux +Operating System: any -PHP Version: 5.4.18 +PHP Version: 5.4 or later
 [2013-08-22 10:38 UTC] yohgaki@php.net
Ini settings are scanned by zend_ini_scanner.c

http://lxr.php.net/xref/PHP_TRUNK/Zend/zend_ini_scanner.l#592

    zend_error(E_DEPRECATED, "Comments starting with '#' are deprecated in %s on 
line %d", zend_ini_scanner_get_filename(TSRMLS_C), SCNG(lineno));

If getting filename and lineno at this stage, error message could be improved. 

"Comments starting with '#' in php config file are deprecated" or like.
 [2013-08-22 10:39 UTC] yohgaki@php.net
> If getting filename and lineno at this stage, error message could be improved.

If getting filename and lineno is not feasible at this stage, error message could 
be improved.
 [2013-08-22 22:37 UTC] yohgaki@php.net
Looked into a bit.
fpm_conf.c parse config file as string and line by line. Therefore, zend ini 
scanner does not know filename nor line number.

http://lxr.php.net/xref/PHP_TRUNK/sapi/fpm/fpm/fpm_conf.c#1502

I guess this ini scanner usage is not expected by the authors.

Adding flag that allows "#" as comment will resolve this issue, but I'm not sure 
if this is the best resolution.
 [2021-08-19 15:42 UTC] cmb@php.net
-Package: Scripting Engine problem +Package: FPM related
 [2021-08-31 13:43 UTC] cmb@php.net
> Adding flag that allows "#" as comment will resolve this issue,
> but I'm not sure if this is the best resolution.

That would not fix the root cause, which is indeed that the lines
are passed one by one to zend_parse_ini_string()[1].  To make the
scanner aware of file and line number, we could set these by
assigning to SCNG(filename) and SCNG(lineno), but that feels
hackish.

[1] <https://github.com/php/php-src/blob/php-7.4.23/sapi/fpm/fpm/fpm_conf.c#L1572>.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 23:01:26 2024 UTC