[vim/vim] fix: ":for" over a tuple leaks memory on every iteration (PR #20914)

2 views
Skip to first unread message

Samuel Schlesinger

unread,
3:39 PM (5 hours ago) 3:39 PM
to vim/vim, Subscribed

Problem: Looping over a tuple with ":for" copies each item with copy_tv() but never clears the copy, leaking the value on every iteration (26MB over 100k iterations of a two-string tuple). Container items keep an extra reference forever, also defeating garbage collection.

Solution: Clear the copied typval on both return paths, like the string branch of next_for_item() already does.

Disclosure: Claude Fable 5 was used to assist with finding this bug. I reviewed this, but I am new to this codebase so forgive me if I am wrong about this problem. This fix was also verified with tests.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/20914

Commit Summary

  • 9a4ad01 fix: ":for" over a tuple leaks memory on every iteration

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20914@github.com>

Samuel Schlesinger

unread,
4:26 PM (4 hours ago) 4:26 PM
to vim/vim, Subscribed
SamuelSchlesinger left a comment (vim/vim#20914)

Looking at other builds, that test appears to be flaky. Let me know if you think it is this PR causing it.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20914/c5153266817@github.com>

Reply all
Reply to author
Forward
0 new messages