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

Haswell config segfaults on macOS with gcc and CFLAGS="-g -O0" #550

Open
devinamatthews opened this issue Sep 28, 2021 · 2 comments
Open

Comments

@devinamatthews
Copy link
Member

devinamatthews commented Sep 28, 2021

The perfect storm happens:

  1. On macOS
  2. With gcc (in my case 11.2)
  3. With debugging enabled (CFLAGS="-g -O0")
  4. Using the haswell configuration

What occurs in my case is that bli_saxpyv_zen_int10 is compiled with flags for AVX, and GCC makes the assumption that the incoming stack pointer is 32-byte aligned. Then, because of the debug flags, horrible code is emitted which spills vector registers (__m256) to the stack. This spilling uses aligned move instructions which require 32-byte alignment. GCC dutifully 32-byte aligns all offsets from the stack pointer to satisfy this constraint. Here is the catch: if the incoming stack point is NOT actually 32-byte aligned (as it isn't in BLIS, since the calling code is not compiled for AVX but for general x86_64), then we encounter a segfault.

It has proven quite difficult to actually force GCC to align the stack using e.g. andq $-32, %rsp. The only thing that seems to work is -mincoming-stack-boundary=3 (not 4!). I will add this to the default haswell flags since so far I can only confirm the problem on a mac. I'll see about Linux shortly.

@devinamatthews
Copy link
Member Author

Linux seems unaffected. Windows is also unaffected according to the internet.

@devinamatthews devinamatthews changed the title Force stack alignment for AVX kernels Haswell config segfaults on macOS with gcc and CFLAGS="-g -O0" Sep 29, 2021
@devinamatthews
Copy link
Member Author

I'll leave this open as a warning to others.

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

Successfully merging a pull request may close this issue.

1 participant