#27759 [Csd]: bcadd() causes crash if first parameter is empty string
| From: | pollita@php.net | Date: | Mon, 26 Jul 2004 17:58:58 +0000 |
| Subject: | #27759 [Csd]: bcadd() causes crash if first parameter is empty string | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-63580@lists.php.net to get a copy of this message | ||
ID: 27759
Updated by: pollita@php.net
Reported By: patrick at rap-x dot com
Status: Closed
Bug Type: BC math related
Operating System: win32 only
PHP Version: 5.0.0RC1
New Comment:
The fix was located just *after* the release of 5.0.0 (literally, like,
the next day), look for it in 5.0.1.
Previous Comments:
------------------------------------------------------------------------
[2004-07-25 00:22:19] davesk78 at yahoo dot com
This bug still exists in the final release (5.0.0). I'm running Apache
2, PHP 5.0.0, and Windows XP Pro. Same test case:
$total = "0";
$diff = "";
$result = bcadd($total, $diff, 6);
echo $result;
exit;
The following also causes Apache to crash:
$total = "0";
$diff = "";
$result = bcpow($total, $diff, 6);
echo $result;
exit;
------------------------------------------------------------------------
[2004-07-07 15:48:45] pk at onpk dot net
The reproduce code still crashes on my box Windows 2000 pro, Apache
1.3.27, PHP5 build 2195. And not only with "bcadd" but also with :
$total = "0";
$diff = "";
bcpow($total, $diff, 6);
And :
$total = "0";
$diff = "";
bcsub($total, $diff, 6);
However I've to admit that ttt_cao at hotmail dot com's remedy does
work. By the way, I'm not using PEAR`s
Benchmark_Timer.
Hope someone will look at this. Thanks in advance.
Perrick :: http://www.onpk.net/
------------------------------------------------------------------------
[2004-06-29 18:51:18] ttt_cao at hotmail dot com
update the function getProfiling() in timer.php as the follows, maybe
you can fix the bug.
function getProfiling() {
$i = 0;
$total = $temp = '0.0';
$result = array();
foreach ($this->markers as $marker => $time) {
if (extension_loaded('bcmath')) {
$diff = bcsub($time, $temp, 6);
if ($i > 0)
$total = bcadd($total, $diff, 6);
} else {
$diff = $time - $temp;
$total = $total + $diff;
}
echo "$time $diff $total <br>";
$result[$i]['name'] = $marker;
$result[$i]['time'] = $time;
$result[$i]['diff'] = $diff;
$result[$i]['total'] = $total;
$this->strlen_max = (strlen($marker) > $this->strlen_max ?
strlen($marker) + 1 : $this->strlen_max);
$temp = $time;
$i++;
}
$result[0]['diff'] = '-';
$this->strlen_max = (strlen('total') > $this->strlen_max ?
strlen('total') : $this->strlen_max);
$this->strlen_max += 4;
return $result;
}
------------------------------------------------------------------------
[2004-06-18 01:21:42] rashid at ds dot pg dot gda dot pl
bug is closed so i dare to add 'me too' so maybe someone will reopen it
:]
php5 rc2: problem exists in both bc_sub and bc_add (PEAR`s
Benchmark_Timer works great as perfect example of this bug)
------------------------------------------------------------------------
[2004-04-26 13:26:06] marv at cyberia dot net dot lb
This bug still exists in PHP5RC2. There isn't a problem with bcmath
itself, but something is corrupting heap memory that bcmath uses.
bcmath allocates three numbers (zero, one, and two) when it first
starts up. If any of these numbers is then used (such as when adding
zero to a number in bcadd) Apache crashes.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/27759
--
Edit this bug report at http://bugs.php.net/?id=27759&edit=1