Anyone with stack alignment error on macOS Catalina and brewed GCC?

Hi there,

I was wondering if anyone has been able to correct or patch an issue arising with non-trivial C/C++/Fortran codes compiled with GCC 9.2 on macOS:

Process 7717 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
    frame #0: 0x00007fff69aaa3a6 libdyld.dylib`stack_not_16_byte_aligned_error
libdyld.dylib`stack_not_16_byte_aligned_error:
->  0x7fff69aaa3a6 <+0>: movdqa %xmm0, (%rsp)
    0x7fff69aaa3ab <+5>: int3   

libdyld.dylib`_dyld_fast_stub_entry:
    0x7fff69aaa3ac <+0>: pushq  %rbp
    0x7fff69aaa3ad <+1>: movq   %rsp, %rbp
Target 0: (main) stopped.

People have been mentioning it there and there, I reported it to Apple developer feedback but I have been told it is not from their side, and that I should rather contact GCC people. Would you agree with that?

Has anyone resolved this issue and could the origin lay in Homebrew? Some workarounds that have been tried involve setting -fno-stack-check or MACOSX_DEPLOYMENT_TARGET=10.14 but without any success for me.

My setup: macOS Catalina 10.15.1, XCode 11.2.1, updated homebrew with GCC 9.2.0

We get this error on some systems when running MUMPS. The crash occurs at

CALL DMUMPS_FREE_ID_DATA_MODULES(id%FDM_F_ENCODING,
& id%BLRARRAY_ENCODING, id%KEEP8(1))

in dana_driver.F

The subroutine is

  SUBROUTINE DMUMPS_FREE_ID_DATA_MODULES(id_FDM_F_ENCODING,
 &  id_BLRARRAY_ENCODING, KEEP8)
  USE MUMPS_FRONT_DATA_MGT_M, only : MUMPS_FDM_STRUC_TO_MOD,
 &                                   MUMPS_FDM_END
  USE DMUMPS_LR_DATA_M, only : DMUMPS_BLR_STRUC_TO_MOD,
 &                             DMUMPS_BLR_END_MODULE

if defined(MUMPS_F2003)

  CHARACTER, DIMENSION(:), POINTER, intent(inout) ::
 &                                            id_BLRARRAY_ENCODING
  CHARACTER, DIMENSION(:), POINTER, intent(inout) ::
 &                                            id_FDM_F_ENCODING

else

  CHARACTER, DIMENSION(:), POINTER :: id_BLRARRAY_ENCODING
  CHARACTER, DIMENSION(:), POINTER :: id_FDM_F_ENCODING

endif

  INTEGER(8), intent(inout) :: KEEP8(150)
  END SUBROUTINE DMUMPS_FREE_ID_DATA_MODULES
  END INTERFACE

C

This is

bsmith@ypro tutorials % gfortran -v

Using built-in specs.

COLLECT_GCC=gfortran

COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/10.2.0/libexec/gcc/x86_64-apple-darwin19/10.2.0/lto-wrapper

Target: x86_64-apple-darwin19

Configured with: …/configure --build=x86_64-apple-darwin19 --prefix=/usr/local/Cellar/gcc/10.2.0 --libdir=/usr/local/Cellar/gcc/10.2.0/lib/gcc/10 --disable-nls --enable-checking=release --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-10 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --with-pkgversion=‘Homebrew GCC 10.2.0’ --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk SED=/usr/bin/sed

Thread model: posix

Supported LTO compression algorithms: zlib

gcc version 10.2.0 (Homebrew GCC 10.2.0)

bsmith@ypro tutorials % clang -v

Apple clang version 11.0.3 (clang-1103.0.32.62)

Target: x86_64-apple-darwin19.6.0

Thread model: posix

InstalledDir: /Library/Developer/CommandLineTools/usr/bin

bsmith@ypro tutorials %

On another system with

$ clang -v

Apple clang version 12.0.0 (clang-1200.0.32.2)

Target: x86_64-apple-darwin19.6.0

Thread model: posix

InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

It runs fine.