Skip to content

Compiler segfaults (stack overflow in LLVM codegen) when a Vec of a type recursive through Vec is dropped #1557

Closed

Description

@ehartford

Found while implementing D61 (#1480), on main ae609cd and the installed v0.15.2.1 alike (not D61-related).

type N { n: i32, next: Vec[N] }
fn main:
    let v: Vec[N] = Vec.new()
    print(f"{v.len()}")

with build exits 139. check and --emit-c succeed; the crash is inside compile_to_object_backend (LLVM backend), a stack overflow reached from rt_alloc_unlocked (lldb: EXC_BAD_ACCESS at a stack guard address; the frames between the crash and Compilation.prepare_binary_link_from_pool+1296 carry no frame records, so lldb cannot unwind them). The drop of Vec[N] is the trigger: removing the local compiles. Likely the drop-glue/type lowering recursing N -> Vec[N] -> N without a guard.

Repro file used: a Vec-recursive tree in the D61 matrix; D61 tests cover recursion through Box instead until this is fixed.

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