Hi,

we've found bug that makes ksh crash after not closing file descriptors from 
autoloaded functions.

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
----------------------------------

We've used following patch to fix this:
diff -up ksh-20101010/src/cmd/ksh93/sh/path.c.fdfn 
ksh-20101010/src/cmd/ksh93/sh/path.c
--- ksh-20101010/src/cmd/ksh93/sh/path.c.fdfn   2010-10-13 15:19:05.472419086 
+0200
+++ ksh-20101010/src/cmd/ksh93/sh/path.c        2010-10-13 15:19:46.909133696 
+0200
@@ -730,6 +730,7 @@ int path_search(Shell_t *shp,register co
                                return(1);
                        }
                        funload(shp,fno,name);
+                       sh_close(fno);
                        return(1);
                }
                *stakptr(PATH_OFFSET) = 0;

_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to