Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infinite loop in superdouble implementation with gcc 13 #178

Closed
emollier opened this issue Aug 12, 2023 · 3 comments
Closed

infinite loop in superdouble implementation with gcc 13 #178

emollier opened this issue Aug 12, 2023 · 3 comments

Comments

@emollier
Copy link

Hi,

Since introduction of gcc 13 in Debian sid, the run_tests.py script hangs at the "character: 2" message after building phyx:

cd src && python3 run_tests.py
character: 0
character: 1
character: 2

Running top reveals a pxstrec process running at 100% cpu. Attaching the hung pxstrec process with gdb reveals the process seems to be caught in an infinite loop during a superdouble calculation:

0x0000560c29677683 in Superdouble::adjustDecimal (this=<optimized out>) at ./src/superdouble.cpp:40
40	        while (std::abs(mantissa) >= 10) {
(gdb) 
(gdb) 
(gdb) 
(gdb) 
(gdb) step
41	            mantissa *= 0.1;
(gdb) 
40	        while (std::abs(mantissa) >= 10) {
(gdb) 
std::abs (__x=-inf) at /usr/include/c++/13/bits/std_abs.h:80
80	  { return __builtin_fabsl(__x); }
(gdb) 
40	        while (std::abs(mantissa) >= 10) {
(gdb) 
0x0000560c29677679 in std::abs (__x=-inf) at /usr/include/c++/13/bits/std_abs.h:80
80	  { return __builtin_fabsl(__x); }
(gdb) 
41	            mantissa *= 0.1;
[...]

On first sight, this looks to be related to excess precision changes documented in porting to gcc 13 guide. Adding -fexcess-precision=fast per recommendation didn't help though. Nevertheless, I managed to get rid of the issue by removing -ffast-math for information, but maybe this is hiding something else:

--- phyx.orig/src/Makefile.in
+++ phyx/src/Makefile.in
@@ -35,8 +35,6 @@
     OPT_FLAGS += -ftree-vectorize
     ifneq ($(filter @host_cpu@,i386 i486 i586 i686),)
         OPT_FLAGS += -ffloat-store
-    else
-        OPT_FLAGS += -ffast-math
     endif
 endif
 

This has been seen on Debian sid with phyx 1.3 with gcc 13.1.0, and phyx 1.3.1 with gcc 13.2.0. The issue is also loosely tracked in Debian Bug#1037817.

@josephwb
Copy link
Member

Thanks for reporting this, and taking a look into the cause.

I'll look at this in the next week, although I did not write this code. I imagine your Makefile fix will be sufficient.

@josephwb
Copy link
Member

Removing -ffast-math doesn't seem to break anything (at least from the make check standpoint). I'll do some code spelunking, but this may be a suitable solution.

josephwb added a commit that referenced this issue Nov 27, 2023
@josephwb
Copy link
Member

This has (finally) been changed. Thanks for finding the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants