*Synopsis*: *ksh93* crashes in script containing uncommon output redirections
CR 6703761 changed on Dec 22 2008 by <User 1-5Q-5151> === Field ============ === New Value ============= === Old Value ============= Root Cause Other - see Research Acti.. ====================== =========================== =========================== *Change Request ID*: 6703761 *Synopsis*: *ksh93* crashes in script containing uncommon output redirections Product: solaris Category: shell Subcategory: korn93 Type: Defect Subtype: Status: 7-Fix in Progress Substatus: Priority: 1-Very High Introduced In Release: solaris_nevada Introduced In Build: snv_72 Responsible Engineer: <User 1-5Q-5151> Keywords: oss-request, oss-sponsor === *Description* ============================================================ Running the following shell script on Indiana (Opensolaris 2005.08) causes ksh to crash: ---------------------- #!/usr/bin/i86/ksh93 rm -f core TMPFILE=/tmp/tmp.$$ temp_links=0 add_tmplink() { [ $temp_links -le 0 ] && echo "" >$TMPFILE && exec 4>&1 temp_links=`expr $temp_links + 1` } POS(){ add_tmplink echo >> $TMPFILE eval "$*" 3>&1 >> $TMPFILE 2>&1 cat $TMPFILE >&4 exec 1>&4 rm $TMPFILE if [ -f core ] ; then echo Core file found fi exit } fun1 () { POS fun2 argument } fun2 () { POS function_3 $1 } function_3 () { echo 111 echo $1 echo 222 echo $1 | cat echo 333 } dummy1 () { : ; } dummy2 () { : ; } dummy3 () { : ; } dummy4 () { : ; } dummy5 () { : ; } dummy6 () { : ; } dummy7 () { : ; } dummy8 () { : ; } dummy9 () { : ; } dummy10() { : ; } dummy11() { : ; } dummy12() { : ; } dummy13() { : ; } dummy14() { : ; } dummydummydummydummy () { : ; } POS fun1 ---------------------- This is perfectly reproducible on several i86pc machines on various versions of Nevada: <email address omitted>:~$ ls -l core /opt/sfw/bin/ls: core: No such file or directory <email address omitted>:~$ ./setuplib [several empty lines] 111 argument 222 333 Core file found <email address omitted>:~$ ls -l ./core -rw------- 1 ps216548 staff 4442198 May 16 16:20 ./core BTW, note that the script is supposed to write 'argument' between '222' and '333' too. MDB says the following: <email address omitted>:~$ mdb core Loading modules: [ libc.so.1 ld.so.1 ] > ::status debugging core file of setuplib (32-bit) from eschaton file: /usr/bin/i86/ksh93 initial argv: /usr/bin/i86/ksh93 ./setuplib threading model: native threads status: process terminated by SIGSEGV (Segmentation Fault) > $c libc.so.1`strlen+0xb(8061280) libshell.so.1`copyto+0x8e7(8061280, 0, 0) libshell.so.1`sh_macexpand+0x185(8073e74, 8035bec, 0) libshell.so.1`arg_expand+0x8b(8073e74, 8035bec, 0) libshell.so.1`sh_argbuild+0x9f(80360c4, 8073e54, 0) libshell.so.1`sh_exec+0x1e6f(8073e54, 5) libshell.so.1`sh_exec+0x32ba(8073e80, 4) ... [a screenful of sh_exec's, sh_eval's, and friends] libshell.so.1`sh_funct+0xe4(8073808, 2, 8067468, 0, 5) libshell.so.1`sh_exec+0x2d37(8067428, 5) libshell.so.1`exfile+0x64c(fef9eca0, 8072368, a) libshell.so.1`sh_main+0x6a0(2, 8047b98, 0) main+0x1d(2, 8047b98, 8047ba4) _start+0x7a(2, 8047c74, 8047c87, 0, 80611f0, 8047d16) The problem is magnified by having /bin/sh linked to /usr/bin/i86/ksh93 in Indiana. *** (#1 of 2): 2008-05-16 14:33:51 GMT+00:00 <User 1-61155F> ;The problem with the script above seems to be that it redirects 3>..., but it does not ;open the fd 3 anywhere. ; ;Still, ksh should respond to the misusage of redirections by an error message instead ;of blowing oneself to pieces. Edit: The conclusion about the problem with the script was hasty. Now I believe there is nothing wrong with the script. *** (#2 of 2): 2008-05-23 15:39:17 GMT+00:00 <User 1-61155F> *** Last Edit: 2008-05-23 16:00:02 GMT+00:00 <User 1-61155F> === *Public Comments* ======================================================== === *Workaround* ============================================================= === *Additional Details* ===================================================== Targeted Release: solaris_nevada Commit To Fix In Build: snv_106 Fixed In Build: Integrated In Build: Verified In Build: See Also: 6619428 Duplicate of: Hooks: Hook1: Hook2: Hook3: Hook4: Hook5: <email address omitted> Hook6: <email address omitted> Program Management: Root Cause: Other - see Research Activity Fix Affects Documentation: No Fix Affects Localization: No === *History* ================================================================ Date Submitted: 2008-05-16 14:33:50 GMT+00:00 Submitted By: <User 1-61155F> Status Changed Date Updated Updated By 6-Fix Understood 2008-10-14 17:15:37 GMT+00:00 <User 1-5Q-5151> 7-Fix in Progress 2008-12-15 23:36:23 GMT+00:00 <User 1-5Q-5151> === *Service Request* ======================================================== Impact: Significant Functionality: Secondary Severity: 3 Product Name: storage-tests Product Release: v4 Product Build: Operating System: solaris_nevada Hardware: Submitted Date: 2008-05-16 14:33:51 GMT+00:00 === *Multiple Release (MR) Cluster* - 0 ======================================