Skip to content

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

Merged
mpeg5 merged 1 commit into
masterfrom
fix_avx_segfault
Aug 7, 2026
Merged

Fix segfault when built with -mavx (#108)#162
mpeg5 merged 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

@mpeg5 mpeg5 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was unsolved long-term issue.
LGTM

@mpeg5
mpeg5 merged commit 903316f into master Aug 7, 2026
6 checks passed
@kpchoi
kpchoi deleted the fix_avx_segfault branch August 8, 2026 05:09
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

2 participants