Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 205037 - vim.eclass -- file handle leakage in gawk code
Summary: vim.eclass -- file handle leakage in gawk code
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All All
: High critical (vote)
Assignee: Vim Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-09 11:54 UTC by Heiko
Modified: 2008-01-09 21:14 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
patch to close the file handles (vim.eclass.gawk.leakage.patch,362 bytes, patch)
2008-01-09 11:57 UTC, Heiko
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Heiko 2008-01-09 11:54:20 UTC
When applying the vim-patches to vim, gawk is used to parse and process the patches.

The gawk code opens each patch in ${WORKDIR}/vimpatches with a call of '(getline tryme < thisfile)'. The problem that arises is that the file handle is NOT closed after reading the patch file. Thus it leaks a file handle for each previously opened patch file -- which vim has a lot of.

The gawk info page [1] explicitely states the following:
"Similarly, when a file or pipe is opened for output, the file name or
command associated with it is remembered by `awk', and subsequent
writes to the same file or command are appended to the previous writes.
The file or pipe stays open until `awk' exits. This implies that special steps are necessary in order to read the same
file again from the beginning, or to rerun a shell command (rather than
reading more output from the same command).  The `close' function makes
these things possible: close(FILENAME) or: close(COMMAND)"

While that vim.eclass gawk code may work on some platforms it may (and will) not work on others. For example on NetBSD this will trigger the following:
[...]
7.1.077: src/syntax.c src/version.c
7.1.078: src/gui.cgawk: cmd. line:31: (FILENAME=- FNR=10173) fatal: too many pipes or input files open
which makes the emerge die.

Anyway, it's not a good coding style to leave unused file handles open

It can be fixed very easily by issuing 'close(thisfile)' after the vim-patch file has been processed. A patch that does so (and works) is appended.


Best regards,

    Heiko.


[1] http://www.scs.cmu.edu/cgi-bin/info2www?(gawk.info)Close%20Files%20And%20Pipes

Reproducible: Always

Steps to Reproduce:
1.emerge vim-core / vim / gvim
2.
3.

Actual Results:  
gawk fails to process the vim-patches after several patch files with the following eror message:
[...]
7.1.077: src/syntax.c src/version.c
7.1.078: src/gui.cgawk: cmd. line:31: (FILENAME=- FNR=10173) fatal: too many pipes or input files open


Expected Results:  
Continue patching.
Comment 1 Heiko 2008-01-09 11:57:05 UTC
Created attachment 140536 [details, diff]
patch to close the file handles

This patch closes the file handles gawk has finished processing.
Comment 2 Ali Polatel (RETIRED) gentoo-dev 2008-01-09 21:14:33 UTC
Fixed. Thanks for reporting :)