Skip to content

collect[String]() leaks its staging Vec #2190

Closed

Description

@ehartford
let xs: Vec[u8] = [65, 66, 67]
let text: str = xs.iter() |> collect[String]()
print(text)

Run with --debug-alloc: LEAK size=16 origin=Vec. The codegen builds a temporary Vec[u8] and copies it with with_str_from_vec_u8, which copies the bytes; the staging buffer is never freed (CodegenDispatch.w, the itercollectstr lowering). Found by test/spec/spec_ss13_3_collect_targets.w under the debug allocator.

Activity

  1. ehartford commented on Oct 5, 2026

    @ehartford
    ContributorAuthor

    Fixed on main by stack #2196 (merged as efb765c), battery green on a21e326; the regression test for it landed with the fix.

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