att / ast

AST - AT&T Software Technology
Eclipse Public License 1.0
558 stars 152 forks source link

ksh93u+ dumps core when fds >32 #1494

Open sowmya573 opened 3 years ago

sowmya573 commented 3 years ago

I have an application which invokes multiple ksh93 scripts and ,where each script might call other and it goes on... and most of the commands are run in subshell enviroment with pipe. ex: $(echo "file1 file2 file3" | grep "file1").

So in a particular situation, application is dumping core in sfsync. After some investigation, I could see that in sh_subtmpfile, "fcntl" call returns fd as "99". But when i tried to print shp->lim.open_max, it shows 32. So it looked like some memory overflow has happened which resulted in coredump. As per my understanding i feel like in sh_subtmpfile, (sp->tmpfd = fd = fcntl(1,F_DUPFD,10) ==> here, replacing fcntl() call with sh_fcntl() call would solve the purpose, which will inturn call the sh_iovalidfd, and that takes care of (fd>max) cases.

So my question here is, is there a global #define of fcntl to sh_fcntl which would take care of such cases. Looks like in my envirnonment, fcntl() is not replaced with sh_fcntl. Did i miss anything during compilation. Please suggest.

Note: This is seen on ksh93u+ version, built on AIX.

McDutchie commented 2 years ago

Hi there, this repo is inactive and AT&T stopped working on ksh93 years ago. My own ksh93 community fork ksh 93u+m has many subshell-related and I/O-related bugs fixed. Could you try building that and see if that fixes the bug? Also, if you get any build errors please let me know – I lost access to any possibility to test on AIX some time ago.