Discussion:
[ast-developers] Weird .sh.name and .sh.subscript values for multidimensional arrays
Tina Harriott
2013-08-30 13:27:55 UTC
Permalink
Latest (sh (AT&T Research) 93v- 2013-08-27) ksh crashes if I
explicitly unset a variable with unset(1) which contains a
multidimensional array:

ksh -c 'compound c;typeset -a c.a ; function c.a.unset { printf
"%s,%s\n" "${.sh.name}" "${.sh.subscript}"; } ; (( c.a[3][6][11][20]=7
, c.a[3][6][300][20]=7 )) ; unset c'
c.a,3
c.a[3][6],11
Segmentation fault

The crash however is not the issue which troubles me. The values of
.sh.name and .sh.subscript are:
I have two elements in the array and would expect three calls of c.a.unset:
1. .sh.name=c.a, .sh.subscript=[3][6][11][20]
2. .sh.name=c.a, .sh.subscript=[3][6][300][20]
3. .sh.name=c.a, .sh.subscript not set (called to dispose the array
object itself)

The real values in .sh.name and .sh.subscript when c.a.unset() is
called are dubious at best.

Tina
--
Tina Harriott - Women in Mathematics
Contact: tina.harriott.math at gmail.com
David Korn
2013-09-03 14:41:41 UTC
Permalink
cc: ast-developers at lists.research.att.com
Subject: Re: [ast-developers] Weird .sh.name and .sh.subscript values for multidimensional arrays
--------
Post by Tina Harriott
ksh -c 'compound c;typeset -a c.a ; function c.a.unset { printf
"%s,%s\n" "${.sh.name}" "${.sh.subscript}"; } ; (( c.a[3][6][11][20]=7
, c.a[3][6][300][20]=7 )) ; unset c'
c.a,3
c.a[3][6],11
Segmentation fault
The crash however is not the issue which troubles me. The values of
1. .sh.name=c.a, .sh.subscript=[3][6][11][20]
2. .sh.name=c.a, .sh.subscript=[3][6][300][20]
3. .sh.name=c.a, .sh.subscript not set (called to dispose the array
object itself)
The real values in .sh.name and .sh.subscript when c.a.unset() is
called are dubious at best.
Tina
--
The crash is a bug, but the name and subscript are not.

It should call the unset function with:
name subscript
c.a[3] 6
c.[3][6] 11
c.[3][6][300] 20
However, it crashed before the last unset call.



David Korn
dgk at research.att.com

Loading...