Segmentation fault with mpz_inp_raw on gcc45

Paul Zimmermann Paul.Zimmermann at inria.fr
Wed Sep 15 12:40:22 UTC 2021


       Hi,

with gmp-6.2.1 and the following program:

zimmerma at gcc45:~/ecm$ cat test.c
#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>

main()
{
  mpz_t s;
  FILE *file;
  int ret;
  mpz_init (s);
  file = fopen ("test_dummy2.save", "rb");
  ret = mpz_inp_raw (s, file);
}

I get a Segmentation fault on gcc45 with the following file:

$ cat test_dummy2.save
-e

# this is a comment line and should be ignored

gdb says:

Program received signal SIGSEGV, Segmentation fault.
__mempcpy_ia32 () at ../sysdeps/i386/i686/multiarch/../mempcpy.S:50
50      ../sysdeps/i386/i686/multiarch/../mempcpy.S: No such file or directory.
(gdb) where
#0  __mempcpy_ia32 () at ../sysdeps/i386/i686/multiarch/../mempcpy.S:50
#1  0xb7e72388 in __GI__IO_file_xsgetn (fp=0x804a008, data=0x8a7b200a, 
    n=761596426) at fileops.c:1388
#2  0xb7e74138 in __GI__IO_sgetn (fp=fp at entry=0x804a008, 
    data=data at entry=0x8a7b200a, n=n at entry=761596426) at genops.c:495
#3  0xb7e67a19 in __GI__IO_fread (buf=0x8a7b200a, size=761596426, count=1, 
    fp=0x804a008) at iofread.c:42
#4  0x080486f4 in __gmpz_inp_raw ()
#5  0x08048602 in main () at test.c:12

I suspect the issue is due to "-e" in the first line, since there is no error
if I remove that line.

Paul


More information about the gmp-bugs mailing list