Opened 4 years ago

Last modified 21 months ago

#60356 new defect

MacPorts gcc 9.3.0 internal compiler error: Segmentation fault: 11 - not seen with Homebrew gcc 9.3.0

Reported by: attiliodefalco Owned by:
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: david.sagan@…, cooljeanius (Eric Gallager)
Port: gcc9

Description (last modified by mf2k (Frank Schima))

The following code fails to compile with MacPorts gcc 9.3.0 but not Homebrew gcc 9.3.0

#include <math.h>
 double vec_dist ()
 {double r=0;
 return sqrt(r);
 }

And compile with:

    gcc -O2 -ffast-math -c test.c

The output is:

test.c: In function 'vec_dist':
test.c:6:1: internal compiler error: Segmentation fault: 11
}
^
test.c:6:1: internal compiler error: Abort trap: 6
gcc: internal compiler error: Abort trap: 6 (program cc1)

This reproduces on my 4-year old laptop, but not my 5-year old mini. Both are currently running 10.15.4 (usually the mini runs betas) and have gcc 9.3.0 from MacPorts. On the laptop, this segfaults the compiler when compiled with '-O2 -ffastmath':

extern double sqrt(double);
double mad_vec_dist () { double r=0; return sqrt(r); }

(note that I removed the include of math.h). Changing sqrt() to sin() also segfaults. However, this compiles fine:

extern double trqs(double);
double vec_dist () { double r=0; return trqs(r); }

and the ones that segfault the compiler don't segfault if I add the '-fno-builtin' flag--so it's something about the optimization of the builtin math functions that are enabled by -ffastmath. This is likely actually a bug in the upstream gcc but I don't see the segfault with Homebrew gcc 9.3 (or even on CentOS 7 gcc 9.3).

Please let me know if I should notify GNU, as well.

Thanks!

Attilio

Change History (6)

comment:1 Changed 4 years ago by mf2k (Frank Schima)

Port: gcc9 added

In the future, please fill in the Port field.

comment:2 Changed 4 years ago by mf2k (Frank Schima)

Description: modified (diff)

comment:3 Changed 4 years ago by mf2k (Frank Schima)

Description: modified (diff)

comment:4 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)

I'm not sure that anybody here can help you with this, especially since nobody has volunteered to be the maintainer of the gcc ports. You may need to research the issue yourself, possibly with the assistance of the developers of gcc, if you want a solution.

A segmentation fault is a crash. When a crash happens, macOS records a crash log in Library/Logs/DiagnosticReports. The contents of that crash log may help pinpoint what was happening when the crash occurred. Attaching it here may help someone else help you further.

comment:5 Changed 4 years ago by kencu (Ken)

We have a lot more configure options set in our gcc builds -- which the gcc lead has warned me about already, as it can make our builds somewhat different that the usual, tested builds... but even so, the only thing I can see that gets my attention comparing homebrew's gcc9 formula and our gcc9 Portfile is this one interesting addition and mention of an issue with the linking <https://github.com/Homebrew/homebrew-core/blob/431813dff13cee10ff6e3392ee41b04d55a4668c/Formula/gcc.rb#L93> and at this second, I can't see how that might be connected to the segfault...

Like Ryan said, if we can see the crashlog, maybe something can be gleaned from it.

comment:6 Changed 21 months ago by cooljeanius (Eric Gallager)

Cc: cooljeanius added
Note: See TracTickets for help on using tickets.