Skip to content

LLVM closure cells lay out an over-aligned capture (§16.4) at LLVM's alignment, not TypeLayout's #2042

Closed

Description

@ehartford

Found with #2039. let held = Al { a: 5, v: 3 } (@[align(32)] v) captured by move () => (&raw const held.v as i64) % 32 reads false: the owned heap cell {drop_fn, clone_fn, env} (CodegenDispatch, closure owned_cell path and the env clone fn) is allocated with with_alloc(abi_size_of(cell_ty)) and its literal LLVM struct places env, and Al inside the capture struct, at LLVM's ABI alignment (Al's i8-padded body reports 8), not the model's 32. Expected: the cell and capture struct take TypeLayout's alignment, as tuples do since #1964 (tuple_type_from_layout), and the cell is allocated with with_alloc_aligned (#2039). The C backend's cells are already correct after #2039 (with_alloc_aligned of sizeof/_Alignof of a cell whose records carry _Alignas).

Activity

  1. ehartford commented on Oct 3, 2026

    @ehartford
    ContributorAuthor

    Fixed on fix-2036 (PR #2044, commit 0577d56). Closure and async environments now take TypeLayout's tuple placement, and the owned cell puts the environment at its own alignment. The cell, its clone and async environments are allocated with with_alloc_aligned. Fixture: behav_2042_closure_env_over_aligned.

  2. added a commit that references this issue on Oct 3, 2026
  3. ehartford commented on Oct 3, 2026

    @ehartford
    ContributorAuthor

    Fixed on main (stack #2045: #2037 + #2044; seed-driven battery GREEN on 0577d56, tree identical to main).

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions