Bug #18313 Updated: elusive recursion-related crash

From: Date: Fri, 12 Jul 2002 12:53:05 +0000
Subject: Bug #18313 Updated: elusive recursion-related crash
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-13978@lists.php.net to get a copy of this message
ID: 18313 Updated by: admin@finance-on.net Reported By: admin@finance-on.net Status: Open Bug Type: Reproducible crash Operating System: linux, 2.4 kernel PHP Version: 4.2.1 New Comment: the isoCompare, when used on a page, will cause it to show up as "document contains no data" ... on some reloads, whereas sometimes it will be fine, using the same inputs. i have not been able to find anything that could be tweaked to change the frequency of crashes. they seem random. as a temporary measure we have moved to the iterative version. i'm quite worried about whether there is a problem with our setup or is this actually an issue in php 4.2.x -- we have not encountered this problem before, the code used to run fine. Previous Comments: ------------------------------------------------------------------------ [2002-07-12 08:49:15] admin@finance-on.net i am sorting an array of strings using uasort($a,'isoCompare'). the user function isoCompare, in its recursive variant, crashes randomly. first, the support function charPower which remaps diacritical chars... this one is ok. function charPower ($ch,$charPowerCaseSensitive=FALSE,$charPowerReverseOrder=FALSE) { $power = 0; $char = ($charPowerCaseSensitive ? $ch : strtoupper($ch)); switch (ord($char)) { case 232: $power = 10*ord(($charPowerCaseSensitive ? "c" : "C") case 200: $power = 10*ord("C")+3; break; case 190: $power = 10*ord(($charPowerCaseSensitive ? "z" : "Z") case 174: $power = 10*ord("Z")+5; break; case 185: $power = 10*ord(($charPowerCaseSensitive ? "s" : "S") case 169: $power = 10*ord("S")+5; break; case 230: $power = 10*ord(($charPowerCaseSensitive ? "c" : "C") case 198: $power = 10*ord("C")+6; break; case 240: $power = 10*ord(($charPowerCaseSensitive ? "d" : "D") case 208: $power = 10*ord("D")+5; break; default: $power = 10*ord($char); } return ($charPowerReverseOrder ? ((-1)*$power) : $power); } ; now the recursive isoCompare... function isoCompare ($s1,$s2) { $len1 = strlen($s1); $len2 = strlen($s2); if ($len1==0 || $len2==0) { $ret = $len1 - $len2; if (!$ret) return 0; else return $ret > 0 ? +1 : -1; } ; $c1 = charPower($s1); $c2 = charPower($s2); $power1 = charPower($c1) ; $power2 = charPower($c2) ; if ($power1==$power2) { $ret = isoCompare(substr($s1,1), substr($s2,1)); return $ret; } else { $ret = $power1-$power2; return $ret > 0 ? +1 : -1; } } the iterative version works fine: function isoCompare ($s1, $s2) { global $isadmin; $i = 0; $ret = 0; while (!$ret) { $len1 = strlen($s1); $len2 = strlen($s2); if ($len1 == 0 && $len2 == 0) $ret = 0; elseif ($len1 == 0) $ret = 1; elseif ($len2 == 0) $ret = -1 ; else { $power1 = charPower(substr($s1,0,1)) ; $power2 = charPower(substr($s2,0,1)) ; if ($power1 > $power2) $ret = 1; elseif ($power2 > $power1) $ret = -1; else { $s1 = substr($s1,1); $s2 = substr($s2,1); } ; } ; } ; // while return $ret; } ; my setup: ./configure \ --with-config-file-path=/usr/local/lib \ --with-zlib \ --with-mysql=/usr/local/mysql \ --with-exec-dir=/usr/local/safe_mode --enable-track-vars=yes \ --enable-magic-quotes=yes --disable-debug \ --with-pdflib \ --with-xml \ --with-sablot=/usr/local/lib \ --with-expat=/usr/local/lib \ --enable-sysvsem \ --enable-sysvshm \ --with-gd \ --with-iconv \ --with-curl=/usr/local/curl \ --with-apxs=/usr/local/apache/bin/apxs ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=18313&edit=1

« previous php.bugs (#13978) next »