i have following php script call via cli:
#!/usr/bin/php <?php $max_stellen = 10; ($base=2; $base<=62; $base++) { ($power=2; $power<=10; $power++) { $result = array(); $max_base = gmp_pow($base, $max_stellen); $x = gmp_init(0); while ((gmp_cmp($x, $max_base) == -1)) { $val = gmp_strval($x, $base); $i = strlen($val); $left = gmp_pow($x, $power); $right = gmp_pow($base, $i); $mod = gmp_mod($left, $right); if (gmp_cmp($mod, $x) == 0) { $result[] = $val; } unset($left); unset($right); unset($mod); $x = gmp_add($x, 1); // !!! line 30 } unset($x); unset($max_base); $res2 = array(); foreach ($result &$r) { $root = substr($r, -1); $res2[$root][] = $r; } unset($result); foreach ($res2 $root => &$r) { echo "x^${power}_${base}($root) = {".implode(', ', $r)."}\n"; } unset($res2); echo "\n"; } }
after short time (values base=6, power=9
), following error message:
php warning: gmp_add(): -2147483648 not valid gmp integer resource in ... on line 30
if manually run code base=6, power=9
, works, error happens when loop running multiple times.
the error message sounds there gmp handles allocated not freed when not used anymore. after short time, handle out of integer range. how free gmp handles? tried use unset()
everywhere, , functions gmp_free()
or gmp_destroy()
not exist.
update
reported issue php, since believe not expected behavior: https://bugs.php.net/bug.php?id=69702
Comments
Post a Comment