Segmentation fault when printing large numbers
Jeff Epler
jepler at gmail.com
Wed Apr 28 12:21:36 UTC 2021
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.
Problem exists with the development version at changeset:
18211:92681f2490cc (April 16) as well as with 6.1.2+dfsg-4 as published by
Debian for Buster.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bigg.c
Type: text/x-csrc
Size: 408 bytes
Desc: not available
URL: <https://gmplib.org/list-archives/gmp-bugs/attachments/20210428/8d711fc6/attachment.bin>
More information about the gmp-bugs
mailing list