Here is the attached script from the bug...

#!/bin/ksh93 -p
#
# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I%     %E% SMI"

function create_input_file
{
        input_file=/tmp/coreme.txt
        cp -f /dev/null /tmp/coreme.txt

        cat > /tmp/coreme.txt <<EOF
Z "-z ls" "gtar -z"
y "-y" "shutdown -y"
throwaway "all entires" "read so far"
A "-a" "ls -a"
B "-b" "cpio -b"
C "-c" "tar -c"
D "-d" "make -d"
EOF
}


function process_input_file
{
        typeset -i line_num=0

        set -A argname
        set -A argvalue
        set -A argtype

        typeset specific

        while read argtype[$line_num] specific; do
                eval set -A argvars -- $specific
                if [[ ${argtype[$line_num]} == "throwaway" ]]; then
                        line_num=0
                        unset argname argtype argvalue
                        set -A argname
                        set -A argtype
                        set -A argvalue
                        continue
                fi
                if [[ -z "${argvars[1]}" ]]; then
                        skip=1
                fi
                argname[$line_num]=${argvars[0]}
                argvalue[$line_num]=${argvars[1]}
                ((line_num = line_num + 1))
        done < /tmp/coreme.txt

        set +x
}

#
# main
#

print "Expected output is:
type    name    value
A       -a      ls -a
B       -b      cpio -b
C       -c      tar -c
D       -d      make -d"

print "
Start script ..."

create_input_file
process_input_file

print "End script
..."

typeset -i idx=0

print "type \t name \t value"

for i in ${argtype[*]}; do
        print "${argtype[$i]} \t ${argname[$i]} \t ${argvalue[$i]}"
        ((i = i + 1))
done

> X-Original-To: ksh93-integration-discuss at opensolaris.org
> Delivered-To: ksh93-integration-discuss at opensolaris.org
> Date: Tue, 17 Jun 2008 16:32:26 -0400
> From: David Korn <dgk at research.att.com>
> To: ksh93-integration-discuss at opensolaris.org
> Subject: Re: [ksh93-integration-discuss] CR 6715496 Updated P2 shell/korn93 
ksh93 SEGVs on array reinitialization
> List-Id: Korn Shell 93 integration/migration project discussion 
<ksh93-integration-discuss.opensolaris.org>
> 
> Subject: Re: [ksh93-integration-discuss] CR 6715496 Updated P2 shell/korn93  
ksh93 SEGVs on array reinitialization
> --------
> 
> > *Synopsis*: ksh93 SEGVs on array reinitialization
> > 
> > CR 6715496 changed on Jun 17 2008 by <User 1-6Y4MMS>
> > 
> > === Field ============ === New Value ============= === Old Value 
=============
> > 
> > Work Around            New Note                                             
> >   
> > ====================== =========================== 
===========================
> > 
> > 
> > *Change Request ID*: 6715496
> > 
> > *Synopsis*: ksh93 SEGVs on array reinitialization
> > 
> >   Product: solaris
> >   Category: shell
> >   Subcategory: korn93
> >   Type: Defect
> >   Subtype: 
> >   Status: 1-Dispatched
> >   Substatus: 
> >   Priority: 2-High
> >   Introduced In Release: 
> >   Introduced In Build: 
> >   Responsible Engineer: 
> >   Keywords: 
> > 
> > === *Description* 
============================================================
> > ksh93 dumps core when an array variable previously declared with "set -A 
vname" 
> > is reinitialized
> > by redeclaring it using "set -A vname".  
> > 
> > By reinitializing, we mean throwing away all array data that has been 
assigned s
> > o far and 
> > recreating the array as a freshly created 'set -A' variable would -- with 
> > no 
ini
> > tial data
> > until specifically assigned.
> > 
> > Attached are a script that reproduces the bug and a core file produced when 
the 
> > script was run.
> > 
> > *** (#1 of 1): 2008-06-17 13:57:39 GMT+00:00 <User 1-5Q-8946>
> > 
> > 
> > === *Workaround* 
=============================================================
> > Instead of using simply 'set -A vname' to reinitialize the array, use
> >         set -A vname -- ""
> > This creates an array of size 1.
> > 
> > Do note that this is NOT exactly identical to "set -A vname" which 
> > creates an array of ZERO size (i.e., ${vname[*]} returns 0).
> > 
> > *** (#1 of 2): 2008-06-17 13:57:39 GMT+00:00 <User 1-5Q-8946>
> > 
> > AFAIK it should be possible to do an $ unset arrayname # before the $ set 
> > -A 
arr
> > ayname # to work around this problem, too.
> > 
> > *** (#2 of 2): 2008-06-17 20:09:48 GMT+00:00 <User 1-6Y4MMS>
> > 
> > 
> 
> I tried to reproduce on Linux without success with the following:
> ============cut here==========
> set -A vname  -- foo bar
> set -A vname 
> ============cut here==========
> 
> Is this correct?  If not, what sequence reproduces it?
> 
> 
> David Korn
> dgk at research.att.com
> _______________________________________________
> ksh93-integration-discuss mailing list
> ksh93-integration-discuss at opensolaris.org
> http://mail.opensolaris.org/mailman/listinfo/ksh93-integration-discuss


Reply via email to