wangtongada / gmpy

Automatically exported from code.google.com/p/gmpy
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Unable to convert huge mpz to string #14

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. e = mpz(8)
2. p = e**(e**e)
3. s = str(s)
(this will cause a segfault)
What is the expected output? What do you see instead?
The expected output is a large number

Version details:
sam@sam-laptop:~$ apt-cache showpkg python-gmpy
Package: python-gmpy
Versions: 
1.01.dfsg.1-1
(/var/lib/apt/lists/gb.archive.ubuntu.com_ubuntu_dists_hardy_universe_binary-amd
64_Packages)
(/var/lib/dpkg/status)
 Description Language: 
                 File:
/var/lib/apt/lists/gb.archive.ubuntu.com_ubuntu_dists_hardy_universe_binary-amd6
4_Packages
                  MD5: 8560c6a67d4864a412cfe666232e460a

Reverse Depends: 
Dependencies: 
1.01.dfsg.1-1 - python-central (2 0.5.8) python (3 2.6) python (2 2.4)
libc6 (2 2.5-5) libgmp3c2 (0 (null)) 
Provides: 
1.01.dfsg.1-1 - python2.5-gmpy python2.4-gmpy 
Reverse Provides: 

Original issue reported on code.google.com by Samphip...@googlemail.com on 18 Oct 2008 at 12:04

GoogleCodeExporter commented 8 years ago
Can't reproduce on the equipment at my disposal (which is 32-bit, not 64-bit) 
and more modern releases of 
gmpy (1.02 and up).  Passing to Case who, I believe, does have 64-bit machines 
to try this out; most likely this is 
a bug fixed in some release after 1.01 and the remedy will be for you to 
upgrade your gmpy installation.

Original comment by alea...@gmail.com on 18 Oct 2008 at 5:47

GoogleCodeExporter commented 8 years ago
should be s = str(p) not s = str(s) that causes the problem.

Original comment by Samphip...@googlemail.com on 18 Oct 2008 at 6:21

GoogleCodeExporter commented 8 years ago
also, I have just downloaded the gmpy-1.03 version from the downloads page and 
the
error is reproduced.

sam@sam-laptop:~/gentoo/gmpy-1.03$ python
Python 2.5.2 (r252:60911, Jul 31 2008, 17:31:22) 
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gmpy import *
>>> e = mpz(8)
>>> p = e**(e**e)
>>> s = str(p)
Segmentation fault
sam@sam-laptop:~/gentoo/gmpy-1.03$ 

Original comment by Samphip...@googlemail.com on 18 Oct 2008 at 6:25

GoogleCodeExporter commented 8 years ago
I've fixed this bug in svn. The fix may cause a slight slowdown for mpz->string
conversions. If the slowdown is noticeable, I'll work on a more sophisticate 
patch.

casevh

Original comment by casevh on 19 Oct 2008 at 12:40

GoogleCodeExporter commented 8 years ago
Fixed by changing memory allocation for temporary objects.

Thanks for the bug report.

Case

Original comment by casevh on 3 Jan 2009 at 11:44