Incorrect memory alignment of components.
Author: RobertBiehlCreated Aug 31, 2021Updated May 5, 2026
Labelsbughas a workaround
Describe the bug Component structs passed to system do not adhere to the defined memory alignment correctly.
To Reproduce
enable avx
Create component with aligned struct, e.g.
typedef struct EcsTransform3 {
__attribute((aligned(32))) mat4 value;
} EcsTransform3;- Inside system check address of pointer to struct
void TestSystem(ecs_iter_t* it) {
EcsTransform3 *transform = ecs_term(it, EcsTransform3, 1);
printf("(EcsTransform3 *) addr = %#010x", transform);
}Sometimes prints addresses not aligned to 32 bytes as expected from CGLM_ALIGN_MAT. (In my case this was 0x000000011af54ef0, which is only divisible by 16, not by 32.) This causes crashes in calls to AVX intrinsics.
Expected behavior Address of component should be aligned correctly, in this case to 32 bytes.
Additional context Add any other context about the problem here (operating system, hardware, ...).
Source: SanderMertens/flecs