Summary: | dev-lang/php-5 - segfaults in file_check_mem (fileinfo module) | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Jens Maus <mail> |
Component: | [OLD] Development | Assignee: | PHP Bugs <php-bugs> |
Status: | RESOLVED DUPLICATE | ||
Severity: | normal | CC: | andrey, citizen3942, dirk.olmes, KevinOfOz, mail, randalla, tom, waffel |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
URL: | https://bugs.php.net/bug.php?id=64836 | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- |
Description
Jens Maus
2013-04-28 15:16:17 UTC
Just an additional comment/note after having debugged the situation even further. When reconfiguring apache and php for fpm (fastcgi) support and then trying to run the above mentioned php scripts everything seems to work fine as well and they do not crash apache anymore. So somehow the problem seem to be related to using mod_php with apache. I can confirm this issue, on my system I can reproduce it with the example Some further comments on how I managed to work around the problem by switching apache2 from mod_php to php-fpm usage: 1) edited /etc/portage/package.use and added use flag "fpm" to dev-lang/php 2) remerged php by "emerge php" 3) installed fastcgi module via "emerge mod_fastcgi_handler" 4) edited /etc/conf.d/apache2 added "-D FASTCGI_HANDLER" and removed "-D PHP5" 5) edited /etc/php/fpm-php5.4/php-fpm.conf and changed "listen" statement to use a socket via "listen = /var/run/php-fpm.sock" 6) edited /etc/apache2/modules.d/20_mod_fastcgi_handler.conf and added AddHandler fcgi:/var/run/php-fpm.sock .php .php5 .phtml .phps DirectoryIndex index.php index.phtml at the end of the <IfDefine> 7) restarted apache and started php-fpm After switching to php-fpm using this procedure the apache crashes are instantly gone and my example scripts work as expected. Thus, I highly suspect mod_php being the cultrip. Did you create an upstream bug at bugs.php.net yet? If not, please do so and reference the bug here. I reported this bug on php.net, which might be related. https://bugs.php.net/bug.php?id=64836 Sadly I cannot reproduce it anymore... I can confirm that downgrading sys-apps/file to 5.11 and then upgrade again to current version (5.12-r1) solves the issue. This is documented in the upstream bug by R Biegel. Sadly I was too hasty in trying out to see whether it could also be fixed by only re-emerging the current version of sys-apps/file. Anyway, this seems to be the workaround. I can confirm , that the problem still exists (also with the newer sys-apps/file-5.15). Also a downgrade of sys-apps/file does not help every time. The problem also exists with a combination of latest stable apache2 and php-5.5.7 (amd64). Small update: this code works: -- cut here -- <?php $finfo = finfo_open(FILEINFO_MIME); if($finfo) { $mime_type = finfo_file($finfo, "/tmp/blah.txt"); echo $mime_type . "\n"; finfo_close($finfo); } ?> -- cut here -- but the following code produces a crash (segfault): -- cut here -- <?php $mime_type = @mime_content_type("/tmp/blah.txt"); echo $mime_type . "\n"; ?> -- cut here -- I removed " -D SVN -D DAV" from /etc/conf.d/apache2 and now mediawiki no longer segfaults apache. I'm using the following versions of stuff people mention on a hardened 64-bit system: sys-apps/file-5.1.7 www-servers/apache-2.2.27 dev-lang/php-5.5.12 I don't mind since I'm not really using subversion anymore. This is just a very weird interaction bug. Wow ... what a strange behavior. I have only removed the SVN module from apache conf. Now my mediawiki also comes back. Thanks for this hint! Possible someone figure out the root cause of such problem. I've run into this bug, or something very similar today. I upgraded our mediawiki to 1.23.1, and lost the ability to load CSS (at the very least). Turns out that Apache was crashing when doing the call to load.php inside of the mediawiki.legacy.shared module. After pouring through the code, it's this line here: return finfo_file( finfo_open( FILEINFO_MIME_TYPE ), $realpath ); I isolated the above down to this: # cat test.php <?php var_dump( finfo_file( finfo_open( FILEINFO_MIME_TYPE ), __FILE__ ) ); ?> This file's not important, but it does need to exist. Executing that in a browser causes the empty response error (read, crash). As found above, if you remove SVN from the /etc/conf.d/apache2 file, the above PHP code works. Calling the code from the command line does NOT reproduce this issue. It must be through www-servers/apache + dev-vcs/subversion and the apache2 conf.d file having -D SVN enabled. I'm running the stable versions of: dev-lang/php-5.3.28-r3 www-servers/apache-2.2.27 dev-vcs/subversion-1.7.14 My /etc/conf.d/apache2 configuration: APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D PHP5 -D PROXY -D DAV -D DAV_FS -D SVN -D AUTHN_PAM -D LDAP -D AUTHNZ_LDAP" I'll be happy to post my emerge --info if it's relevant. I stumbled upon the same issue when I updated my Mediawiki to the latest version (1.23.5). My PHP Version is 5.4.34-pl0-gentoo (apache2handler) And MySQL 5.5.40-log When I turned off Apache dependency on SVN from /etc/conf.d/apache2 then Mediawiki loaded stylesheets effortlessly. When the SVN dependency is turned on then the stylesheet does not load. It is very odd that SVN somehow affects Mediawiki and runs into segfaults. I really need to use SVN on my server and I would not like to switch the SVN on/off whenever I need to use it, yet I cannot do that my wiki page is in use all the time. I tried to recomple php, apache, svn-dav, but with no success. I really hope that some of you can come up with a reasonable solution for that. (In reply to Andres from comment #12) > I stumbled upon the same issue when I updated my Mediawiki to the latest > version (1.23.5). > My PHP Version is 5.4.34-pl0-gentoo (apache2handler) > And MySQL 5.5.40-log > > When I turned off Apache dependency on SVN from /etc/conf.d/apache2 then > Mediawiki loaded stylesheets effortlessly. When the SVN dependency is turned > on then the stylesheet does not load. > > It is very odd that SVN somehow affects Mediawiki and runs into segfaults. > > I really need to use SVN on my server and I would not like to switch the SVN > on/off whenever I need to use it, yet I cannot do that my wiki page is in > use all the time. > > I tried to recomple php, apache, svn-dav, but with no success. > > I really hope that some of you can come up with a reasonable solution for > that. Now I decided to dig in to Mediawiki PHP code and I commented out the mime_content_type(). Mediawiki already had fileinfo() php function present so i needed to comment out following lines in following Mediawiki files: 901-912:./includes/MimeMagic.php 146-149:./includes/libs/CSSMin.php 1034-1036:./includes/libs/lessc.inc.php Now I turned on Apache SVN dependency and php did not run into segfault. And best of all - now it is possible to use SVN again. I hope I pulled together the solution as the possible solution in changing the PHP code was already suggested by Thomas Wabner. (In reply to Andres from comment #13) > (In reply to Andres from comment #12) > > I stumbled upon the same issue when I updated my Mediawiki to the latest > > version (1.23.5). > > My PHP Version is 5.4.34-pl0-gentoo (apache2handler) > > And MySQL 5.5.40-log > > > > When I turned off Apache dependency on SVN from /etc/conf.d/apache2 then > > Mediawiki loaded stylesheets effortlessly. When the SVN dependency is turned > > on then the stylesheet does not load. > > > > It is very odd that SVN somehow affects Mediawiki and runs into segfaults. > > > > I really need to use SVN on my server and I would not like to switch the SVN > > on/off whenever I need to use it, yet I cannot do that my wiki page is in > > use all the time. > > > > I tried to recomple php, apache, svn-dav, but with no success. > > > > I really hope that some of you can come up with a reasonable solution for > > that. > > Now I decided to dig in to Mediawiki PHP code and I commented out the > mime_content_type(). Mediawiki already had fileinfo() php function present > so i needed to comment out following lines in following Mediawiki files: > 901-912:./includes/MimeMagic.php > 146-149:./includes/libs/CSSMin.php > 1034-1036:./includes/libs/lessc.inc.php > > Now I turned on Apache SVN dependency and php did not run into segfault. And > best of all - now it is possible to use SVN again. > > I hope I pulled together the solution as the possible solution in changing > the PHP code was already suggested by Thomas Wabner. Sorry. It was too early to tell, because I forgot to clean browser cache. An d the problem still remains. (In reply to Andres from comment #14) > (In reply to Andres from comment #13) > > (In reply to Andres from comment #12) > > > I stumbled upon the same issue when I updated my Mediawiki to the latest > > > version (1.23.5). > > > My PHP Version is 5.4.34-pl0-gentoo (apache2handler) > > > And MySQL 5.5.40-log > > > > > > > Now I decided to dig in to Mediawiki PHP code and I commented out the > > mime_content_type(). Mediawiki already had fileinfo() php function present > > so i needed to comment out following lines in following Mediawiki files: > > 901-912:./includes/MimeMagic.php > > 146-149:./includes/libs/CSSMin.php > > 1034-1036:./includes/libs/lessc.inc.php > > > > Now I turned on Apache SVN dependency and php did not run into segfault. And > > best of all - now it is possible to use SVN again. > > > > I hope I pulled together the solution as the possible solution in changing > > the PHP code was already suggested by Thomas Wabner. > > Sorry. It was too early to tell, because I forgot to clean browser cache. An > d the problem still remains. The easy way to fix this issue for end-users is to disable the fileinfo extension, either by disabling the (by default enabled) 'fileinfo' USE flag for dev-lang/php and recompile, or by editing the php.ini file. I did not find any php application in my environment that actually required the extension to be available. (In reply to Tom Hendrikx from comment #15) > (In reply to Andres from comment #14) > > (In reply to Andres from comment #13) > > > (In reply to Andres from comment #12) > > > > I stumbled upon the same issue when I updated my Mediawiki to the latest > > > > version (1.23.5). > > > > My PHP Version is 5.4.34-pl0-gentoo (apache2handler) > > > > And MySQL 5.5.40-log > > > > > > > > > > Now I decided to dig in to Mediawiki PHP code and I commented out the > > > mime_content_type(). Mediawiki already had fileinfo() php function present > > > so i needed to comment out following lines in following Mediawiki files: > > > 901-912:./includes/MimeMagic.php > > > 146-149:./includes/libs/CSSMin.php > > > 1034-1036:./includes/libs/lessc.inc.php > > > > > > Now I turned on Apache SVN dependency and php did not run into segfault. And > > > best of all - now it is possible to use SVN again. > > > > > > I hope I pulled together the solution as the possible solution in changing > > > the PHP code was already suggested by Thomas Wabner. > > > > Sorry. It was too early to tell, because I forgot to clean browser cache. An > > d the problem still remains. > > The easy way to fix this issue for end-users is to disable the fileinfo > extension, either by disabling the (by default enabled) 'fileinfo' USE flag > for dev-lang/php and recompile, or by editing the php.ini file. > > I did not find any php application in my environment that actually required > the extension to be available. Now I did a core dump debug with gdb and the backtrace is following: GNU gdb (Gentoo 7.7.1 p1) 7.7.1 Copyright (C) 2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-pc-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://bugs.gentoo.org/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from apache2...(no debugging symbols found)...done. [New LWP 28905] warning: Could not load shared library symbols for linux-vdso.so.1. Do you need "set solib-search-path" or "set sysroot"? [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Core was generated by `/usr/sbin/apache2 -D CGI -D SSL -D PHP5 -D SVN -D DAV -D SVN_AUTHZ -D STATUS -D'. Program terminated with signal SIGSEGV, Segmentation fault. #0 0x00007f1c7236bd0a in ?? () from /usr/lib64/apache2/modules/libphp5.so (gdb) bt full #0 0x00007f1c7236bd0a in ?? () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #1 0x00007f1c7236b4b7 in ?? () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #2 0x00007f1c7236bab3 in file_softmagic () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #3 0x00007f1c72367c43 in file_buffer () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #4 0x00007f1c72368440 in ?? () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #5 0x00007f1c7235e762 in ?? () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #6 0x00007f1c7266797f in ?? () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #7 0x00007f1c72620c2f in execute () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #8 0x00007f1c725b1cf8 in zend_call_function () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #9 0x00007f1c725b20c0 in call_user_function_ex () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #10 0x00007f1c7232427f in php_pcre_replace_impl () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #11 0x00007f1c723248a0 in ?? () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #12 0x00007f1c72324e83 in ?? () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #13 0x00007f1c7266797f in ?? () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #14 0x00007f1c72620c2f in execute () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #15 0x00007f1c725b1cf8 in zend_call_function () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #16 0x00007f1c725b20c0 in call_user_function_ex () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #17 0x00007f1c7232427f in php_pcre_replace_impl () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #18 0x00007f1c723248a0 in ?? () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #19 0x00007f1c72324e83 in ?? () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #20 0x00007f1c7266797f in ?? () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #21 0x00007f1c72620c2f in execute () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #22 0x00007f1c725c09a7 in zend_execute_scripts () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #23 0x00007f1c72560d50 in php_execute_script () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #24 0x00007f1c7266975d in ?? () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #25 0x000000000043b248 in ap_run_handler () No symbol table info available. #26 0x000000000043b6ae in ap_invoke_handler () No symbol table info available. #27 0x00000000004485a0 in ap_process_request () No symbol table info available. #28 0x00000000004455a0 in ?? () No symbol table info available. #29 0x0000000000441918 in ap_run_process_connection () No symbol table info available. #30 0x000000000044cf5f in ?? () No symbol table info available. ---Type <return> to continue, or q <return> to quit--- #31 0x000000000044d67c in ?? () No symbol table info available. #32 0x000000000044e1d2 in ap_mpm_run () No symbol table info available. #33 0x000000000042676d in main () No symbol table info available. Now I went for full world update and the gdb report is as following: GNU gdb (Gentoo 7.7.1 p1) 7.7.1 Copyright (C) 2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-pc-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://bugs.gentoo.org/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from apache2...(no debugging symbols found)...done. [New LWP 20615] warning: Could not load shared library symbols for linux-vdso.so.1. Do you need "set solib-search-path" or "set sysroot"? [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Core was generated by `/usr/sbin/apache2 -D CGI -D SSL -D PHP5 -D DAV -D SVN -D SVN_AUTHZ -D STATUS -D'. Program terminated with signal SIGABRT, Aborted. #0 0x00007fd8bb705555 in raise () from /lib64/libc.so.6 (gdb) bt full #0 0x00007fd8bb705555 in raise () from /lib64/libc.so.6 No symbol table info available. #1 0x00007fd8bb7069cb in abort () from /lib64/libc.so.6 No symbol table info available. #2 0x00007fd8bb746cb0 in ?? () from /lib64/libc.so.6 No symbol table info available. #3 0x00007fd8bb74c956 in ?? () from /lib64/libc.so.6 No symbol table info available. #4 0x00007fd8bb74d78c in ?? () from /lib64/libc.so.6 No symbol table info available. #5 0x00007fd8b2d02ca3 in ?? () from /usr/lib64/libmagic.so.1 No symbol table info available. #6 0x00007fd8b208b385 in finfo_resource_destructor () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #7 0x00007fd8b22fc61e in list_entry_destructor () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #8 0x00007fd8b22fa3a3 in zend_hash_del_key_or_index () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #9 0x00007fd8b22fc737 in _zend_list_delete () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #10 0x00007fd8b2394ee0 in ?? () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #11 0x00007fd8b234e16f in execute () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #12 0x00007fd8b22df238 in zend_call_function () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #13 0x00007fd8b22df600 in call_user_function_ex () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #14 0x00007fd8b205176f in php_pcre_replace_impl () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #15 0x00007fd8b2051d90 in ?? () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #16 0x00007fd8b2052373 in ?? () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #17 0x00007fd8b2394ebf in ?? () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #18 0x00007fd8b234e16f in execute () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #19 0x00007fd8b22df238 in zend_call_function () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #20 0x00007fd8b22df600 in call_user_function_ex () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #21 0x00007fd8b205176f in php_pcre_replace_impl () from /usr/lib64/apache2/modules/libphp5.so ---Type <return> to continue, or q <return> to quit--- No symbol table info available. #22 0x00007fd8b2051d90 in ?? () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #23 0x00007fd8b2052373 in ?? () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #24 0x00007fd8b2394ebf in ?? () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #25 0x00007fd8b234e16f in execute () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #26 0x00007fd8b22edee7 in zend_execute_scripts () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #27 0x00007fd8b228e280 in php_execute_script () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #28 0x00007fd8b2396c9d in ?? () from /usr/lib64/apache2/modules/libphp5.so No symbol table info available. #29 0x000000000043b248 in ap_run_handler () No symbol table info available. #30 0x000000000043b6ae in ap_invoke_handler () No symbol table info available. #31 0x00000000004485a0 in ap_process_request () No symbol table info available. #32 0x00000000004455a0 in ?? () No symbol table info available. #33 0x0000000000441918 in ap_run_process_connection () No symbol table info available. #34 0x000000000044cf5f in ?? () No symbol table info available. #35 0x000000000044d67c in ?? () No symbol table info available. #36 0x000000000044e1d2 in ap_mpm_run () No symbol table info available. #37 0x000000000042676d in main () No symbol table info available. So the segfault problem transformed into SIGABRT. Any suggestions? *** Bug 509516 has been marked as a duplicate of this bug. *** I'm going to mark a bunch of these as duplicates of the bug that has the most information (and an upstream bug -- unfortunately closed). The problem seems to be bundled libmagic code in PHP that can conflict with other stuff. And the solution is probably to unbundle that code. *** This bug has been marked as a duplicate of bug 471682 *** (In reply to Andres from comment #12) > I stumbled upon the same issue when I updated my Mediawiki to the latest > version (1.23.5). > My PHP Version is 5.4.34-pl0-gentoo (apache2handler) > And MySQL 5.5.40-log > > When I turned off Apache dependency on SVN from /etc/conf.d/apache2 then > Mediawiki loaded stylesheets effortlessly. When the SVN dependency is turned > on then the stylesheet does not load. > > It is very odd that SVN somehow affects Mediawiki and runs into segfaults. > > I really need to use SVN on my server and I would not like to switch the SVN > on/off whenever I need to use it, yet I cannot do that my wiki page is in > use all the time. > > I tried to recomple php, apache, svn-dav, but with no success. > > I really hope that some of you can come up with a reasonable solution for > that. Thanks a ton for this tip - disabling dav_svn and dav helped fix the problem, on a FreeBSD box I'm running Phabricator! |