On Wed, 28 Apr 2021, Jeff Epler wrote:

The attached program creates a rather large number, then attempts to print
it.  The printing step encounters a segmentation fault.

Typical error traceback as seen by gdb:
Program received signal SIGSEGV, Segmentation fault.
__memmove_avx_unaligned_erms () at
../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:500
500 ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S: No such file
or directory.
(gdb) where
#0  __memmove_avx_unaligned_erms () at
../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:500
#1  0x000055555555cb3c in __gmp_asprintf_memory (d=0x7fffffffe2e0,
str=0x7ffeff624010 "", len=18446744071562067968) at asprntffuns.c:48
#2  0x000055555555d042 in __gmp_doprnt_integer (funs=0x555555583d80
<__gmp_asprintf_funs_noformat>, data=0x7fffffffe2e0, p=0x7fffffffe340,
s=0x7ffeff624010 "") at doprnti.c:125
#3  0x0000555555556ad0 in __gmp_doprnt_integer_ostream (o=...,
p=0x7fffffffe340, s=0x7ffeff624010 "") at osdoprnti.cc:60
#4  0x0000555555556a09 in operator<< (o=..., z=0x7fffffffe3d0) at
osmpz.cc:46
#5  0x0000555555556934 in operator<< <__mpz_struct [1], __mpz_struct [1]>
(o=..., expr=...) at ./gmpxx.h:2181
#6  0x0000555555556428 in main (argc=2, argv=0x7fffffffe528) at bigg.c:16

It appears that the character-size of strings at some layer
(__gmp_doprnt_integer?) is restricted to INT_MAX bytes of output.

Using int for the length in that file is certainly a bad sign. Generally, formatted I/O hits limitations in GMP, see for instance https://gmplib.org/list-archives/gmp-bugs/2015-November/003795.html and various other reports. It may be possible to fix some of the printing functions without any ABI break, but not others...

--
Marc Glisse
_______________________________________________
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs

Reply via email to