Skip to content

A discarded v.pop() result (Option[str]) is never dropped: the payload leaks #1786

Closed

Description

@ehartford

Spec

§2.5.1 (leaking requires a deliberate, visible act), §9.1 (a statement's value is discarded — and dropped).

Repro

fn main:
    var v: Vec[str] = Vec.new()
    v.push("abc".clone())
    v.push("de".clone())
    v.pop()
    let _ = v.pop()
    print(v.len())

with run --debug-alloc on the base stage1 (76cf0bf) and on batch2-ownership:

0
debug-alloc: LEAK addr=... size=16 origin=unknown
debug-alloc: leak count=1

One of the two popped Some("...") values is never dropped (the other is). Found while writing the D72 test for #1431: v.pop() of a Vec[Fd] never ran Fd.drop for the popped element in statement position.

Expected

Both popped values dropped at the end of their statements; leak count=0.

Activity

  1. added 6 commits that reference this issue on Sep 28, 2026
    6d9e929
    9aff25a
    b75a09f
    745bbd8
    80089cd
    ec2e530
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