Skip to content

O1HeapPool rejects over-aligned allocations on hosts with alignof(max_align_t) > O1HEAP_ALIGNMENT #64

Description

@emrainey

Problem

O1HeapPoolTest.OverAlignedAllocationsAreServedAtMaxAlignment fails in CI (native LLVM/GCC on ubuntu). The test requests allocate(1, 2 * alignof(std::max_align_t)) and expects a pointer aligned at alignof(max_align_t).

On glibc alignof(max_align_t)==16, so the request is 32. O1HeapPool::allocate rejects alignment > O1HEAP_ALIGNMENT (== 16 on 64-bit) with nullptr (modules/jarnax/source/cyphal/O1HeapPool.cpp:27), so the test assert pointer != nullptr fails.

On macOS/arm64 alignof(max_align_t)==8, the request computes to 16, the guard does not trip and the test passes locally — hence it only surfaced in CI.

Expected

The test comment documents the intended behavior: o1heap does not reject alignment requests beyond max_align_t; it serves the block at its own (O1HEAP_ALIGNMENT) granularity. The guard contradicts that.

Fix

Drop the alignment > O1HEAP_ALIGNMENT rejection in O1HeapPool::allocate so over-aligned requests are served at the pool's granularity; add/extend a unit test that exercises an alignment strictly greater than O1HEAP_ALIGNMENT, asserting the returned pointer is aligned at O1HEAP_ALIGNMENT.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions