memory leak when adding an item to a tuple fails

Open
#21,595 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 13 days

Nobody has claimed this yet.

  • #21596 by @yegappan — closed without merging

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
c
Domain
tooling

Research direction

Start with the aid_tuple_append allocation path named in the reproducer, then run the provided Vim script under Valgrind with leak checking enabled. Done means the allocation failure displays E342: Out of memory! without leaking memory; a linked pull request is already open.

Written by the indexing model from the issue text.

Description

AI assisted bug
Steps to reproduce
let v:testing = 1
let s = 'ab'
let t1 = (1,)
let t2 = (s .. 'cd',)
" 34 is aid_tuple_append
call test_alloc_fail(34, 0, 0)
try | let x = t1 + t2 | catch | endtry
call test_alloc_fail(0, 0, 0)
qa!

Reproduced with valgrind --leak-check=full vim -u NONE -i NONE -N -X --not-a-term -es -S repro.vim. The same leak happens for let x = t3[0 : 1] where t3 has string items, and for a tuple literal whose first item is a string, let x = (s .. 'x', 2).

Expected behaviour

The message E342: Out of memory! is displayed and no memory leak.

Version of Vim

9.2.1202

Environment

Linux (Ubuntu)

Dominant language
Vim Script
Stars
41.4k
Forks
6.2k
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vim/vim

All issues in vim/vim

Similar issues

More DevTools issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.