segfault in mpz_divexact()

Antony Dovgal antony at zend.com
Wed Apr 18 15:44:30 CEST 2007


On 04/18/2007 05:28 PM, Torbjorn Granlund wrote:
> Antony Dovgal <antony at zend.com> writes:
> 
>   >   GDB backtrace is not very informative.
>   > 
>   > Yes, it is.  :-) The __gmp_divide_by_zero function is there,
>   > suggesting that GMP detects an operand error.
>   
>   Uhm, sorry about that, pasted wrong bt.
>   This is the correct one:
>   
>   Program received signal SIGSEGV, Segmentation fault.
>   0x40087f91 in __gmpn_submul_1 () from /usr/lib/libgmp.so.3
>   (gdb) bt
>   #0  0x40087f91 in __gmpn_submul_1 () from /usr/lib/libgmp.so.3
>   #1  0x4009b2e8 in __gmpz_cdiv_r_ui () from /usr/lib/libgmp.so.3
>   #2  0x4022c544 in ?? ()
>   #3  0x4022c71c in ?? ()
>   #4  0x400912ae in __gmpn_bdivmod () from /usr/lib/libgmp.so.3
>   #5  0x400792ca in __gmpz_divexact () from /usr/lib/libgmp.so.3
>   
> Alright, now I too see a SIGSEGV.
> 
> Unfortunately, my attempts at reproducing failed.

>The GMP version number, and if pre-packaged or patched then say so. 
Clean build of GMP 4.2.1, no patches whatsoever.

>The configuration options you used when building GMP, if any. 
Just ./configure --prefix=/path/to

>The name of the compiler and its version. For gcc, get the version with `gcc -v', otherwise perhaps `what `which cc`', or similar. 
# gcc -v
Reading specs from /usr/lib/gcc-lib/i586-suse-linux/3.3.5/specs
Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --enable-languages=c,c++,f77,objc,java,ada --disable-checking --libdir=/usr/lib --enable-libgcj --with-slibdir=/lib --with-system-zlib --enable-shared --enable-__cxa_atexit i586-suse-linux
Thread model: posix
gcc version 3.3.5 20050117 (prerelease) (SUSE Linux)

>The output from running `uname -a'. 

Linux hp 2.6.11.4-20a-default #1 Wed Mar 23 21:52:37 UTC 2005 i686 i686 i386 GNU/Linux

>The output from running `./config.guess', and from running `./configfsf.guess' (might be the same). 

pentium4-pc-linux-gnu and i686-pc-linux-gnu accordingly.

The problem is also reproducible on an other machine (Linux x86-64 this time with completely different Linux and GCC).
The only change I has to do is to add some digits to B:
  //mpz_init_set_str(b, "23345555555555555555555555", 0); // works
  mpz_init_set_str(b, "23345554444444444444444555555555555444444555555", 0); //segfaults

I guess if you try adding more digits you'll reproduce it sooner or later.

-- 
Wbr, 
Antony Dovgal


More information about the gmp-bugs mailing list