Skip to content

regressions: fix crashes due to under-aligned heap allocations - #291

Merged
sbahra merged 1 commit into
concurrencykit:masterfrom
nickhutchinson:alignment-fix
Sep 29, 2026
Merged

sbahra merged 1 commit into
concurrencykit:masterfrom
nickhutchinson:alignment-fix

Conversation

@nickhutchinson

Copy link
Copy Markdown
Contributor

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.

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.

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.
@sbahra
sbahra merged commit 928db9c into concurrencykit:master Sep 29, 2026
18 checks passed
@sbahra

sbahra commented Sep 29, 2026

Copy link
Copy Markdown
Member

Thank you!

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.

2 participants