mpz_mul core dump - attempt 2

Kate Minola kminola at po0.glue.umd.edu
Fri Sep 3 22:58:59 CEST 2004


The following C code seg faults on the 
sparc-SunOS architecture (but not on
other architectures that I have tried):

--------------------------------------
#include "gmp.h"
int main()
{
  gmp_randstate_t rstate;
  mpz_t a, b;
  mpz_init(a);
  mpz_init(b);
  gmp_randinit_default(rstate);
  mpz_urandomb(a, rstate, 1 << 26);
  mpz_mul(b, a, a);
}
--------------------------------------
  
% uname -a
SunOS portia 5.8 Generic_108528-15 sun4u sparc SUNW,Sun-Blade-100
% 
% ./config.guess
ultrasparc2-sun-solaris2.8
%
% ./configfsf.guess
sparc-sun-solaris2.8
% 

This is with gmp-4.1.3 built with "--disable-shared" using 

% gcc -v 
Reading specs from /usr/local/gcc-3.4.1/sparc-SunOS/lib/gcc/sparc-sun-solaris2.8/3.4.1/specs
Configured with: ../gcc-3.4.1/configure --enable-languages=c
--prefix=/usr/local/gcc-3.4.1/sparc-SunOS
Thread model: posix
gcc version 3.4.1
% 

To check if the problem is due to the gcc compiler, I
rebuilt gmp-4.1.3 with "cc -x02 -xarch=v9" (cc -V says "Sun
C 5.5 Patch 112760-10 2004/06/01).  Again I got a core
dump with the above code, so the problem is NOT due
to the compiler - unless two distinct compilers have the
same problem.

gdb gives:

Program received signal SIGSEGV, Segmentation fault.
0x000000010000c9bc in __gmpn_sub_n ()
(gdb) bt
#0  0x000000010000c9bc in __gmpn_sub_n ()
#1  0x0000000100005710 in mpn_fft_norm_modF (rp=0x1029154e0, ap=0xffffffff7ffe5c70, n=2112, 
    an=2067) at mul_fft.c:480
#2  0x00000001000062b0 in mpn_mul_fft_internal (op=0x1029154e0, n=0x1029194e0, m=0x1029154e0, 
    pl=2112, k=7, K=128, Ap=0xffffffff7ffeec70, Bp=0xffffffff7ffee870, A=0xffffffff7ffdd070, 
    B=0xffffffff7ffe5c70, nprime=34, l=16, Mp=17, _fft_l=0xffffffff7ffdcf10,
    T=0xffffffff7ffdcf50, rec=1) at mul_fft.c:591
#3  0x0000000100004fb8 in mpn_fft_mul_modF_K (ap=0xffffffff7fff3300, bp=0xffffffff7fff3300, 
    n=2112, K=2048) at mul_fft.c:366
#4  0x0000000100005c38 in mpn_mul_fft_internal (op=0x1019154c0, n=0x1009154a0, m=0x1009154a0, 
    pl=2097152, k=11, K=2048, Ap=0xffffffff7fff3300, Bp=0xffffffff7ffef300, A=0x1029154e0, 
    B=0x104a194e0, nprime=2112, l=1024, Mp=66, _fft_l=0xffffffff7ffff520, 
    T=0xffffffff7fff7300, rec=0) at mul_fft.c:535
#5  0x0000000100006bd4 in __gmpn_mul_fft (op=0x1019154c0, pl=2097152, n=0x1009154a0, 
    nl=-1048576, m=0x1009154a0, ml=-1048576, k=11) at mul_fft.c:683
#6  0x0000000100006d34 in __gmpn_mul_fft_full (op=0x1009154b0, n=0x1001154a0, nl=1048576, 
    m=0x1001154a0, ml=1048576) at mul_fft.c:710
#7  0x000000010000329c in __gmpn_sqr_n (prodp=0x1009154b0, up=0x1001154a0, un=1048576)
    at mul.c:92
#8  0x00000001000032fc in __gmpn_mul (prodp=0x1009154b0, up=0x1001154a0, un=1048576, 
    vp=0x1001154a0, vn=1048576) at mul.c:112
#9  0x0000000100002138 in __gmpz_mul (w=0xffffffff7ffffae0, u=0xffffffff7ffffaf0, 
    v=0xffffffff7ffffaf0) at ../../gmp-4.1.3/mpz/mul.c:138
#10 0x000000010000148c in main () at foo.c:10

Kate Minola
University of Maryland, College Park


More information about the gmp-bugs mailing list