Comment 3 for bug 2023424

Revision history for this message
Dimitry Andric (dimitry.unified-streaming.com) wrote :

There is something weird going on here. I'm seeing the same thing with Ubuntu 24.04's gcc 13.2.0-23ubuntu4, after hitting some issues with x264 (which declared a local variable with __attribute__((aligned(64))) but then it actually wasn't aligned as such, and some AVX512 function then segfaults due to unaligned access).

In my case I can compile the following example on Ubuntu 22.04, and the resulting binary asserts:

#undef NDEBUG
#include <assert.h>
#include <stdio.h>
#include <stdint.h>

int main(void)
{
  char c __attribute__((__aligned__(64)));
  uintptr_t addr = (uintptr_t)&c;
  printf("explicitly aligned char: %#lx\n", addr);
  assert(addr % 64 == 0);
  return 0;
}

$ gcc -fsanitize=address asan-align.c -o asan-align

$ ./asan-align
explicitly aligned char: 0x7f6e19000020
asan-align: asan-align.c:11: main: Assertion `addr % 64 == 0' failed.
Aborted

However, running _exactly_ the same binary on Ubuntu 22.04 does not assert. E.g.:

$ ./asan-align
explicitly aligned char: 0x7ffd1fea4e40

So it looks like there is something that causes main()'s stack to be differently aligned. Whether that is due to Ubuntu 22.04 and 24.04 having different crt*.o files, or due to some AddressSanitizer difference, is not clear to me yet.