|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-06-07 09:16 UTC] php at mike2k dot com
Description:
------------
The simple code below somehow magically triggers a segfault.
PHP is compiled with
'./configure' '--enable-fastcgi' '--enable-discard-path' '--enable-force-cgi-redirect' '--enable-cli'
'--with-mysql' '--with-mysqli=/usr/bin/mysql_config' '--with-curl' '--enable-mbstring' '--with-zlib' '--with-gd' '--enable
-track-vars' '--enable-inline-optimization' '--disable-rpath' '--disable-ipv6' '--disable-debug' '--with-jpeg-dir=/usr' '--
with-png-dir=/usr' '--with-freetype-dir' '--enable-gd-native-ttf' '--enable-shmop' '--with-xsl' '--enable-sockets' '--enabl
e-pcntl' '--with-mcrypt' '--with-bz2' '--enable-sqlite-utf8' '--with-tidy' '--with-pcre-dir' '--enable-exif'
NO bytecode caches or optimizers currently running either.
Reproduce code:
---------------
<?
$uri = ereg_replace('^/bootstrap.php', '', $_SERVER['PATH_INFO']).'/';
function uri_check($uri, $level) {
global $config;
$uri = substr($uri, 0, strrpos($uri, '/'));
if(file_exists($config['base_dir'].$uri.'.php') || file_exists($config['base_dir'].$uri.'/index.php')) {
}
uri_check($uri, $level+1);
}
uri_check($uri, 1);
?>
Expected result:
----------------
Webserver returns a bad gateway 502 error.
This shows up in dmesg/system logs, one per request:
php-cgi[10541]: segfault at 0000007fbf3ffd48 rip 00000000006d7055 rsp 0000007fbf3ffd50 error 6
php-cgi[10546]: segfault at 0000007fbf3ffd48 rip 00000000006d7055 rsp 0000007fbf3ffd50 error 6
php-cgi[10548]: segfault at 0000007fbf3ffd48 rip 00000000006d7055 rsp 0000007fbf3ffd50 error 6
php-cgi[10535]: segfault at 0000007fbf3ffd48 rip 00000000006d7055 rsp 0000007fbf3ffd50 error 6
php-cgi[10596]: segfault at 0000007fbf3fff98 rip 00000000006d7055 rsp 0000007fbf3fffa0 error 6
Actual result:
--------------
it's a pretty simple recursive function. no classes, nothing. putting that code by itself in a file without any other code (includes, anything) consistently crashes. hopefully it does for someone else who is more skilled with the debugging process.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 08:00:02 2025 UTC |
this is the function again: <?php $config['base_dir'] = "/home/foo"; $uri = ereg_replace('^/bootstrap.php', '', $_SERVER['PATH_INFO']).'/'; function uri_check($uri, $level) { global $config; $uri = substr($uri, 0, strrpos($uri, '/')); if(file_exists($config['base_dir'].$uri.'.php') || file_exists($config['base_dir'].$uri.'/index.php')) { echo "something"; } uri_check($uri, $level+1); } uri_check($uri, 1); ?> it is apparent that the issue is an infinite loop. i need to put the uri_check() call inside of the file_exists() stuff. the expected result would be a friendlier crash. something about a maximum recursion limit reached (i thought that error already existed?)