New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There is a memory leak defect at line 1303 in the file /vim/src/dict.c. #14238
Comments
LSAN doesn't catch this because the dictionary is garbage-collected, and this applies to |
Thank you for your quick response! |
I don't think this should be closed. |
Hello! Are you suggesting that this might be a suspected memory leak defect? I initially thought it was a false alarm, so I closed the issue. I have now reopened it. |
Calling for i in range(1000000)
silent! call extendnew({}, {}, {})
endfor for i in range(1000000)
silent! call extendnew([], [], [])
endfor |
Thank you for your patient response! I believe this indeed is a memory leak defect, and fixing it could be considered. |
Problem: a few memory leaks are found (LuMingYinDetect ) Solution: properly free the memory Fixes the following problems: - Memory leak in f_maplist() fixes: vim/vim#14486 - Memory leak in option.c fixes: vim/vim#14485 - Memory leak in f_resolve() fixes: vim/vim#14484 - Memory leak in f_autocmd_get() related: vim/vim#14474 - Memory leak in dict_extend_func() fixes: vim/vim#14477 fixes: vim/vim#14238 closes: vim/vim#14517 vim/vim@29269a7 Co-authored-by: Christian Brabandt <cb@256bit.org>
Problem: a few memory leaks are found (LuMingYinDetect ) Solution: properly free the memory Fixes the following problems: - Memory leak in f_maplist() fixes: vim/vim#14486 - Memory leak in option.c fixes: vim/vim#14485 - Memory leak in f_resolve() fixes: vim/vim#14484 - Memory leak in f_autocmd_get() related: vim/vim#14474 - Memory leak in dict_extend_func() fixes: vim/vim#14477 fixes: vim/vim#14238 closes: vim/vim#14517 vim/vim@29269a7 Co-authored-by: Christian Brabandt <cb@256bit.org>
Problem: a few memory leaks are found (LuMingYinDetect ) Solution: properly free the memory Fixes the following problems: - Memory leak in f_maplist() fixes: vim/vim#14486 - Memory leak in option.c fixes: vim/vim#14485 - Memory leak in f_resolve() fixes: vim/vim#14484 - Memory leak in f_autocmd_get() related: vim/vim#14474 - Memory leak in dict_extend_func() fixes: vim/vim#14477 fixes: vim/vim#14238 closes: vim/vim#14517 vim/vim@29269a7 Co-authored-by: Christian Brabandt <cb@256bit.org>
Steps to reproduce
1.A pointer named d1 is defined at line 1272 in the file /vim/src/dict.c. This pointer is initialized to argvars[0].vval.v_dict at line 1276. Subsequently, this pointer is passed as an argument to the function dict_copy for copying at line 1291, and the copied memory space is assigned to the pointer d1, as shown in the diagram below:https://github.com/LuMingYinDetect/vim_defects/blob/main/vim_1.png
2.The dict_copy function actually allocates a new dynamic memory area and copies the content of the pointer to this memory area. At line 297 of the dict_copy function, a pointer variable named copy is defined. This pointer variable is allocated a dynamic memory area by the dict_alloc function at line 305. The copy variable is returned at line 355, as shown in the diagram below:https://github.com/LuMingYinDetect/vim_defects/blob/main/vim_2.png
3.Therefore, after the execution of dict_copy, the pointer d1 actually points to a newly allocated dynamic memory area. The content of this dynamic memory area is identical to the original content of d1. When the condition at line 1302 of the program holds true, the function returns at line 1303. During this process, the dynamic memory area pointed to by the pointer d1 is neither used nor freed, thus constituting a memory leak defect, as shown in the diagram below:https://github.com/LuMingYinDetect/vim_defects/blob/main/vim_3.png
Expected behaviour
Fixing the memory leak defect.
Version of Vim
9.1.0188
Environment
Ubuntu 22.04
Logs and stack traces
No response
The text was updated successfully, but these errors were encountered: