Repository navigation
regressions: fix crashes due to under-aligned heap allocations - #291
Merged
Merged
Conversation
Introduce `common_aligned_alloc()` / `common_aligned_free()` to `regressions/common.h`. Use it for heap allocations of over-aligned ConcurrencyKit types. These types are _mostly_ discoverable because they're annotated with `CK_CC_CACHELINE`/`CK_CC_ALIGN` but there are also types like `ck_fifo_mpmc_entry_t` that don't have this annotation themselves but contain struct members that do. This fixes crashes -- alignment faults -- I hit when building ConcurrencyKit for Windows x86 and running the test suite. For 32-bit processes on Windows, `malloc()` guarantees 8-byte alignment only, but GCC assumed it could emit instructions like `movaps` that require 16-byte alignment.
Member
|
Thank you! |
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.
Introduce
common_aligned_alloc()/common_aligned_free()toregressions/common.h. Use it for heap allocations of over-aligned ConcurrencyKit types. These types are mostly discoverable because they're annotated withCK_CC_CACHELINE/CK_CC_ALIGNbut there are also types likeck_fifo_mpmc_entry_tthat don't have this annotation themselves but contain struct members that do.This fixes crashes -- alignment faults -- I hit when building ConcurrencyKit for Windows x86 and running the test suite. For 32-bit processes on Windows,
malloc()guarantees 8-byte alignment only, but GCC assumed it could emit instructions likemovapsthat require 16-byte alignment.There are fewer calls to
common_aligned_free()in this PR than you might expect, but that's because the test suite doesn't appear to free many of its allocations, and I haven't attempted to address that here.