Potential issue with --enable-fat

Emmanuel Lonca emmanuel.lonca at univ-artois.fr
Fri Feb 7 12:11:48 CET 2025


Hi,

I am a frequent user of the GMP library (often through the rust crate 
Rug), and first, I would like to thank you to provide this library.
I am not sure whether I discovered an issue in GMP or if I misunderstood 
something from the documentation.
I apologize in advance if the issue comes from me.

I recently got an issue (crashes due to SIGILL) while using GMP through Rug.
After some investigation, I found out that the MULX instruction (from 
the BMI2 instruction set) was called by __gmpz_sizeinbase on a system 
which CPU does not support it.
I first opened a ticket on the Rug repository (here: 
https://gitlab.com/tspiteri/rug/-/issues/79).

Long story short (more details in the ticket above), GMP was compiled 
with the --enable-fat flag on a machine equipped with a CPU that has the 
BMI2 instruction set (Intel(R) Xeon(R) CPU E5-2637 v4) and used on a 
machine which has not access to these instructions (Intel(R) Xeon(R) CPU 
E5-2643).
To what I understand from the GMP documentation, compiling with the 
--enable-fat flag should produce a library that can be used on any x86 
architecture.

Am I wrong somewhere ?

Cheers,
Emmanuel Lonca.


The GMP version number, and if pre-packaged or patched then say so.
gmp-6.3.0, built from sources

A test program that makes it possible for us to reproduce the bug. 
Include instructions on how to run the program.
The program is linked to this message (in the archive).
1- Extract and go into the extracted directory
2- Execute compile-gmp-fat.sh on a machine with MULX
3- Execute compile-print_sizeinbase.sh on a machine with MULX
4- Execute print_sizeinbase/print_sizeinbase on a machine with MULX: no 
issue
5- Execute compile-print_sizeinbase.sh on a machine without MULX
6- Execute print_sizeinbase/print_sizeinbase on a machine without MULX: 
core dumped

A description of what is wrong. If the results are incorrect, in what 
way. If you get a crash, say so.
See above

If you get a crash, include a stack backtrace from the debugger if it’s 
informative (‘where’ in gdb, or ‘$C’ in adb).
[lonca at nodeB000 gmp-fat]$ gdb ./print_sizeinbase/print_sizeinbase
GNU gdb (GDB) Red Hat Enterprise Linux 8.2-15.el8
[...]
(gdb) run
Starting program: 
/home/cril/lonca/tmp/gmp-fat/print_sizeinbase/print_sizeinbase
Missing separate debuginfos, use: yum debuginfo-install 
glibc-2.28-158.el8.x86_64
size_in_base(0) = 1

Program received signal SIGILL, Illegal instruction.
0x0000000000400c17 in __gmpz_sizeinbase ()
(gdb) bt
#0  0x0000000000400c17 in __gmpz_sizeinbase ()
#1  0x0000000000400826 in print_for ()
#2  0x000000000040089e in main ()

Please do not send core dumps, executables or straces.
Ok

The ‘configure’ options you used when building GMP, if any.
--enable-fat

The output from ‘configure’, as printed to stdout, with any options used.
See configure-output.log.bz2 in the archive

The name of the compiler and its version. For gcc, get the version with 
‘gcc -v’, otherwise perhaps ‘what `which cc`’, or similar.
both computers:
gcc version 8.4.1 20210423 (Red Hat 8.4.1-2) (GCC)

The output from running ‘uname -a’.
computer with MULX: Linux nodeC000 4.18.0-301.1.el8.x86_64 #1 SMP Tue 
Apr 13 16:24:22 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
computer without MULX: Linux nodeB000 4.18.0-301.1.el8.x86_64 #1 SMP Tue 
Apr 13 16:24:22 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

The output from running ‘./config.guess’, and from running 
‘./configfsf.guess’ (might be the same).
config.guess: broadwell-pc-linux-gnu
configfsf.guess: x86_64-pc-linux-gnu

If the bug is related to ‘configure’, then the compressed contents of 
config.log.
See config.log.bz2 in archive

If the bug is related to an asm file not assembling, then the contents 
of config.m4 and the offending line or lines from the temporary 
mpn/tmp-<file>.s.
See config.m4.bz2 in archive.



More information about the gmp-bugs mailing list