David Korn wrote: [snip] > > === *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?
Attached (as "coreme.ksh") is Ravindra's test script which triggers the failure for ast-ksh.2007-04-18 ... ---- Bye, Roland -- __ . . __ (o.\ \/ /.o) roland.mainz at nrubsig.org \__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer /O /==\ O\ TEL <currently fluctuating> (;O/ \/ \O;) -------------- next part -------------- #!/usr/bin/ksh93 -p # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # 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 # unset argtype # unset 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