Linux: Floating point exception error parsing introduction

background

Sometimes when compiling a process on CentOS and running it on other centos, the system gives the following error message:

Floating Point Exception

analyze

1. This error will occur when a program compiled by a higher version of GCC runs in an environment of a lower version of GCC; 

It is caused by running on a low version of glibc after compiling with a high version of gcc glibc.


gcc now uses the hash method --hash-style=gnu when linking, which is said to improve the efficiency of dynamic linking by 50%.

However, the old glibc version does not support it, so if you want to run on the old glibc version, remember to add -Wl, --hash-style=sysv when linking

For example:

gcc -Wl,--hash-type=sysv  -o test test.c       

2. In the case of dividing by 0 in the program, you can use GDB debugging to find the problem code in this case, so I won’t go into details here;

Check if there is division by zero in the code: var/0 var%0

おすすめ

転載: blog.csdn.net/hhd1988/article/details/128117476