RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 643811 - ksh doesn't close the file including the function definition
Summary: ksh doesn't close the file including the function definition
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: ksh
Version: 6.0
Hardware: All
OS: Linux
high
high
Target Milestone: rc
: ---
Assignee: Michal Hlavinka
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On: 642508
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-10-18 07:53 UTC by Michal Hlavinka
Modified: 2011-05-19 13:50 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Prior to this update, ksh did not close a file containing an auto-loaded function definition. After loading several functions, ksh could have easily exceeded the system's limit on the number of open files. With this update, files containing auto-loaded functions are properly closed, thus, the number of opened files no longer increases with usage.
Clone Of: 642508
Environment:
Last Closed: 2011-05-19 13:50:18 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
patch to fix this (434 bytes, patch)
2011-01-05 13:26 UTC, Michal Hlavinka
jskala: review+
Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:0645 0 normal SHIPPED_LIVE ksh bug fix and enhancement update 2011-05-18 17:55:36 UTC

Description Michal Hlavinka 2010-10-18 07:53:20 UTC
+++ This bug was initially created as a clone of Bug #642508 +++

Description of problem:

ksh doesn't close the file including the function definition. So, when it reaches the system limit of the number of files, the ksh script failed on the way. The following is the reproducer.


# cat test.sh
#!/bin/ksh
main()
{
typeset i=0;
typeset a="";
FPATH="lib";
autoload ftest;
 while (( ${i} < 100000 ))
 do a=$(ftest "${i}") || {
        print -r -- "number of transactions : ${i}";
        return 1;
         }
         (( i = ${i} + 1 ))
        done
        print -r -- "number of transactions : ${i}";
}
main "$@";

# cat /lib/ftest
function ftest
{
        print -r -- "$*";
}


# ./test.ksh
test.ksh: line 9: function: not found
number of transactions : 1021


# lsof -p `pgrep ksh`
COMMAND  PID USER   FD   TYPE DEVICE     SIZE    NODE NAME
ksh     3810 root  cwd    DIR  253,0     4096 1104407 /root/ksh
ksh     3810 root  rtd    DIR  253,0     4096       2 /
ksh     3810 root  txt    REG  253,0  1301832  682138 /bin/ksh93
ksh     3810 root  mem    REG  253,0   139416  132340 /lib64/ld-2.5.so
ksh     3810 root  mem    REG  253,0  1717800  132341 /lib64/libc-2.5.so
ksh     3810 root  mem    REG  253,0   615136  132349 /lib64/libm-2.5.so
ksh     3810 root  mem    REG  253,0    23360  132347 /lib64/libdl-2.5.so
ksh     3810 root  mem    REG  253,0 56466976 1563157 /usr/lib/locale/locale-archive
ksh     3810 root    0u   CHR  136,2                4 /dev/pts/2
ksh     3810 root    1u   CHR  136,2                4 /dev/pts/2
ksh     3810 root    2u   CHR  136,2                4 /dev/pts/2
ksh     3810 root    3r  FIFO    0,6            13787 pipe
ksh     3810 root    4w  FIFO    0,6            13787 pipe
ksh     3810 root    5r   REG  253,0       47 1104416 /root/ksh/lib/ftest
ksh     3810 root    6r   REG  253,0       47 1104416 /root/ksh/lib/ftest
ksh     3810 root    7r   REG  253,0       47 1104416 /root/ksh/lib/ftest
ksh     3810 root    8r   REG  253,0       47 1104416 /root/ksh/lib/ftest
ksh     3810 root    9r   REG  253,0       47 1104416 /root/ksh/lib/ftest
ksh     3810 root   10r   REG  253,0      323 1104413 /root/ksh/test.ksh
ksh     3810 root   11r   REG  253,0       47 1104416 /root/ksh/lib/ftest
ksh     3810 root   12r   REG  253,0       47 1104416 /root/ksh/lib/ftest
ksh     3810 root   13r   REG  253,0       47 1104416 /root/ksh/lib/ftest
ksh     3810 root   14r   REG  253,0       47 1104416 /root/ksh/lib/ftest
ksh     3810 root   15r   REG  253,0       47 1104416 /root/ksh/lib/ftest
ksh     3810 root   16r   REG  253,0       47 1104416 /root/ksh/lib/ftest
ksh     3810 root   17r   REG  253,0       47 1104416 /root/ksh/lib/ftest
ksh     3810 root   18r   REG  253,0       47 1104416 /root/ksh/lib/ftest
ksh     3810 root   19r   REG  253,0       47 1104416 /root/ksh/lib/ftest
ksh     3810 root   20r   REG  253,0       47 1104416 /root/ksh/lib/ftest
ksh     3810 root   21r   REG  253,0       47 1104416 /root/ksh/lib/ftest
...
ksh     3810 root 1019r   REG  253,0       47 1104416 /root/ksh/lib/ftest
ksh     3810 root 1020r   REG  253,0       47 1104416 /root/ksh/lib/ftest
ksh     3810 root 1021r   REG  253,0       47 1104416 /root/ksh/lib/ftest
ksh     3810 root 1022r   REG  253,0       47 1104416 /root/ksh/lib/ftest
ksh     3810 root 1023r   REG  253,0       47 1104416 /root/ksh/lib/ftest



Steps to Reproduce:
1. create the reproducer written in Descritpion of Problem.
2. and run.

Actual results:
The opened file "lib/ftest" is not closed properly, and the ksh script aborts on the way.

Expected results:
The opened file "lib/ftest" is closed properly, and the ksh script finishes correctly.

Comment 2 Michal Hlavinka 2011-01-05 13:26:41 UTC
Created attachment 471859 [details]
patch to fix this

Comment 5 Martin Prpič 2011-03-16 15:57:15 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Prior to this update, ksh did not close a file containing an auto-loaded function definition. After loading several functions, ksh could have easily exceeded the system's limit on the number of open files. With this update, files containing auto-loaded functions are properly closed, thus, the number of opened files no longer increases with usage.

Comment 6 errata-xmlrpc 2011-05-19 13:50:18 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-0645.html


Note You need to log in before you can comment on or make changes to this bug.