php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52086 No new line at the end of a included pool file crahes the PHP FPM daemon
Submitted: 2010-06-15 14:49 UTC Modified: 2010-06-19 18:32 UTC
From: admin at saltwaterc dot net Assigned: fat (profile)
Status: Closed Package: FPM related
PHP Version: 5.3.2 OS: *
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: admin at saltwaterc dot net
New email:
PHP Version: OS:

 

 [2010-06-15 14:49 UTC] admin at saltwaterc dot net
Description:
------------
I have a script that automatically generates pool configurations based on input parameters and a template configuration. It didn't used to place a new line at the end of the generated configuration file which degenerated into a hard to debug error as the daemon crashes without any useful explanation. By adding a new line after the last configuration line (in my example, php_admin_value[upload_tmp_dir] = /home/example.com/tmp) everything works as expected.

Test script:
---------------
[example.com]
user = example.com
group = example.com
listen = /var/run/php-fpm/example.com.sock
pm = static
pm.max_children = 2
pm.max_requests = 10000
slowlog = /home/example.com/logs/fpm/slow.log
chdir = /home/example.com/docroot
php_admin_value[error_log] = /home/example.com/logs/fpm/error.log
php_admin_value[open_basedir] = /home/example.com/docroot:/home/example.com/sessions:/home/example.com/tmp
php_admin_value[session.save_path] = /home/example.com/sessions
php_admin_value[upload_tmp_dir] = /home/example.com/tmp

Expected result:
----------------
Successful PHP FPM daemon start.

Actual result:
--------------
Starting php-fpm PHP:  syntax error, unexpected $end in Unknown on line 1
Jun 15 12:35:12.090707 [ERROR] Unable to include /usr/local/zend/etc/fpm.d/example.com.ini from /usr/local/zend/etc/php-fpm.conf at line 23
*** glibc detected *** /usr/local/zend/sbin/php-fpm: double free or corruption (fasttop): 0x000000001ac80380 ***
+ backtrace
+ memory map

Patches

fpm-include.error.patch (last revision 2010-06-15 15:07 UTC by fat@php.net)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-15 16:06 UTC] fat@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: fat
 [2010-06-15 17:07 UTC] fat@php.net
The following patch has been added/updated:

Patch Name: fpm-include.error.patch
Revision:   1276614445
URL:        http://bugs.php.net/patch-display.php?bug=52086&patch=fpm-include.error.patch&revision=1276614445
 [2010-06-15 17:08 UTC] fat@php.net
-Status: Assigned +Status: Analyzed
 [2010-06-15 17:08 UTC] fat@php.net
Can you try the attached patch please ?
 [2010-06-19 17:58 UTC] admin at saltwaterc dot net
service php-fpm restart
Gracefully shutting down php-fpm  done
Starting php-fpm PHP:  syntax error, unexpected $end in Unknown on line 1
Jun 19 15:50:58.956049 [ERROR] Unable to include 
/usr/local/zend/etc/fpm.d/default.conf from 
/usr/local/zend/etc/php-fpm.conf at line 8
Jun 19 15:50:58.956439 [ERROR] failed to load configuration file 
'/usr/local/zend/etc/php-fpm.conf'
 failed


It doesn't dump the backtrace and the memory map, but it still crashes. I made a PHP script that writes the configuration to 
/usr/local/zend/etc/fpm.d/:

#!/usr/local/zend/bin/php
<?php
file_put_contents
(
"/usr/local/zend/etc/fpm.d/default.conf",
"[default]
user = php-fpm
group = php-fpm
listen = /var/run/php-fpm/default.sock
pm = static
pm.max_children = 2
pm.max_requests = 10000
chdir = /var/www"
);

This reproduces the bug. If I manually edit the file with nano, everything is fine since nano automatically adds a new line 
at the end of the last line.
 [2010-06-19 18:31 UTC] fat@php.net
Automatic comment from SVN on behalf of fat
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=300604
Log: - Fixed bug #52086 (No new line at the end of a included file crahes the PHP FPM daemon)
 [2010-06-19 18:32 UTC] fat@php.net
-Status: Analyzed +Status: Closed
 [2010-06-19 18:32 UTC] fat@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC