Skip to content

POD Vec[i32] buffer never freed at scope exit (debug-allocator finding) #608

Closed

Description

@ehartford

POD Vec[i32] buffer is never freed (debug-allocator finding, out of scope for #606)

The native debug allocator (with run --debug-alloc, see docs/debug-allocator.md) reports a leak for a POD-element Vec whose buffer is never freed at scope exit:

fn main:
    let ns: Vec[i32] = Vec.new()
    ns.push(1)
    ns.push(2)
    print_i32(ns.len() as i32)
$ with run --debug-alloc pod.w
2
debug-alloc: LEAK addr=… size=… 
debug-alloc: leak count=1

This is distinct from #606 (inline-drop struct fields). It is the narrow drop gate's deliberate behavior: only Drop-element Vecs get with_vec_free at scope exit; POD-element Vecs (Vec[i32], Vec[str], …) are treated as cheap copyable handles and their buffers are not freed (freeing them was the abandoned "wide flip" — src/CodegenDispatch.w mir_emit_drop_vec_ptr returns false for POD-element Vecs). The buffer is reclaimed by the OS at process exit, so it is a true heap leak in long-running code, not a use-after-free or double-free.

Captured here so the debug allocator's view of it is pinned (fixture test/debug_alloc/da_pod_vec.w, //! expect-debug-alloc: leak count=1). Not chased — surfaced for prioritization.

Activity

  1. ehartford commented on Jul 2, 2026

    @ehartford
    ContributorAuthor

    Closing as by-design (provisional ruling, reversible): POD-element Vec buffers are deliberately NOT freed at scope exit under the narrow drop gate — Vec[T] needs drop iff type_needs_drop(T) (#606/#608 split; docs/debug-allocator.md documents it and test/debug_alloc/da_pod_vec.w PINS the leak-count=1 view so the instrument's expectation is explicit). The 'wide flip' (all Vecs own their buffers) is a separate deliberate project per the A5 handoff record — the compiler pervasively copies POD Vec headers as cheap handles, so the flip is a coordinated migration, not a bug fix. Refile as that project when it's actually scheduled.

  2. added a commit that references this issue on Jul 4, 2026
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