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:
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.
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) _((__aligned_ _(64))) ; "explicitly aligned char: %#lx\n", addr);
{
char c __attribute_
uintptr_t addr = (uintptr_t)&c;
printf(
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.