php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27172 gmp_powm() produces crash
Submitted: 2004-02-06 20:57 UTC Modified: 2004-02-08 23:21 UTC
From: dave@php.net Assigned:
Status: Closed Package: Math related
PHP Version: 5CVS, 4CVS OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dave@php.net
New email:
PHP Version: OS:

 

 [2004-02-06 20:57 UTC] dave@php.net
Description:
------------
gmp_powm() crashes with a floating point exception when the third parameter, the modulo, is called with a "0". This seems to be a problem with GMP itself. I am using GMP 4.1.2. PHP could, however, check to see if this parameter is 0, and call mpz_pow() instead.

Reproduce code:
---------------
<?php
    $a = gmp_powm("2", "31", "0");
?>

Expected result:
----------------
$a = 2147483648;

Actual result:
--------------
Program terminated with signal 8, Arithmetic exception.

#0  0x281df6ce in __gmp_exception (error_bit=2) at errno.c:40
40        __gmp_junk = 10 / __gmp_0;
(gdb) bt
#0  0x281df6ce in __gmp_exception (error_bit=2) at errno.c:40
#1  0x00000206 in ?? ()
#2  0x0807b731 in zif_gmp_powm (ht=3, return_value=0x2820766c, this_ptr=0x0, return_value_used=1)
    at /usr/home/dave/php-5.0.0b3/ext/gmp/gmp.c:839
#3  0x0815e6ee in zend_do_fcall_common_helper (execute_data=0xbfbfe000, op_array=0x81c2134)
    at /usr/home/dave/php-5.0.0b3/Zend/zend_execute.c:2535
#4  0x0815bcef in execute (op_array=0x81c2134) at /usr/home/dave/php-5.0.0b3/Zend/zend_execute.c:1260
#5  0x08145be7 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /usr/home/dave/php-5.0.0b3/Zend/zend.c:1048
#6  0x0811bf17 in php_execute_script (primary_file=0xbfbff6ec) at /usr/home/dave/php-5.0.0b3/main/main.c:1638
#7  0x08164a1d in main (argc=2, argv=0xbfbff74c) at /usr/home/dave/php-5.0.0b3/sapi/cli/php_cli.c:910
#8  0x0806d4a5 in _start ()

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-08 23:21 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 23:01:30 2024 UTC