Skip to content

Fix segfault when built with -mavx (#108) - #162

Open
kpchoi wants to merge 1 commit into
masterfrom
fix_avx_segfault
Open

Fix segfault when built with -mavx (#108)#162
kpchoi wants to merge 1 commit into
masterfrom
fix_avx_segfault

Conversation

@kpchoi

@kpchoi kpchoi commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

XEVE_CTX embeds XEVE_PINTRA/XEVE_PINTER, which contain ALIGNED_32 members,
so the required alignment of the type is 32 bytes. It is however allocated with
plain malloc(), which only guarantees 16 bytes. When built with -mavx, the
compiler relies on the declared alignment and merges adjacent member stores into
aligned vmovdqa instructions, which fault at runtime. This is what crashes
xeve_pintra_create() in #108.

This adds xeve_malloc_align32() / xeve_mfree_align32() and uses them for the
XEVE_CTX / XEVEM_CTX allocations. Note that no SIMD kernel actually requires
aligned buffers (all intrinsics use unaligned load/store), so no other allocation
is affected.

Verified with cmake -DCMAKE_C_FLAGS="-mavx": the crash reproduces before the
change and is gone after, for both MAIN and BASE profiles, single- and
multi-threaded. The produced bitstream is bit-exact with a non-AVX build.

Fixes #108

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Segmentation fault in xeve_pintra_create() when running xeve_app or FFmpeg if compiled with -mavx

1 participant