Fix segfault when built with -mavx (#108) - #162
Open
kpchoi wants to merge 1 commit into
Open
Conversation
Signed-off-by: KP Choi <kp5.choi@samsung.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
XEVE_CTXembedsXEVE_PINTRA/XEVE_PINTER, which containALIGNED_32members,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, thecompiler relies on the declared alignment and merges adjacent member stores into
aligned
vmovdqainstructions, which fault at runtime. This is what crashesxeve_pintra_create()in #108.This adds
xeve_malloc_align32()/xeve_mfree_align32()and uses them for theXEVE_CTX/XEVEM_CTXallocations. Note that no SIMD kernel actually requiresaligned buffers (all intrinsics use unaligned load/store), so no other allocation
is affected.
Verified with
cmake -DCMAKE_C_FLAGS="-mavx": the crash reproduces before thechange 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