Bug 1173668

Summary: Issue with initialization of nested associative arrays
Product: Red Hat Enterprise Linux 6 Reporter: Paulo Andrade <pandrade>
Component: kshAssignee: Michal Hlavinka <mhlavink>
Status: CLOSED ERRATA QA Contact: Martin Kyral <mkyral>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.4CC: mhlavink, mkyral, ovasik
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: ksh-20120801-24.el6 Doc Type: Bug Fix
Doc Text:
A nested associative array contained an unexpected extra empty value after the array was initialized. This update fixes a bug in the associative array initialization code that was causing this problem. As a result, newly-created nested associative arrays are empty as expected.
Story Points: ---
Clone Of:
: 1193557 (view as bug list) Environment:
Last Closed: 2015-07-22 06:56:25 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
ksh-20120801-array.patch none

Description Paulo Andrade 2014-12-12 15:52:48 UTC
This problem is specific to all releases, and fedora, up
to rawhide.

  There is an issue with initialization of nested associative
arrays. The test case is:

---8<---
#!/bin/ksh

typeset -A foo
typeset -A foo[bar]
foo[bar][x]=2
(( foo[bar][x]++ ))
set | grep foo
---8<---

  On recent fedora and rhel, it will print:
---8<---
_='foo[bar]'
foo=([bar]=([0]='' [x]=3) )
---8<---

  I have been told on other systems, earlier ksh would print:
---8<---
foo=([bar]=([0]='' [x]=2) [x]=1)
---8<---

  But the current Fedora and Rhel result is still not
"good". For example, with a smaller test case, just
creating foo[bar]:

---%<---
#!/bin/ksh
typeset -A foo
typeset -A foo[bar]
set | grep foo
---%<---

results in:
---8<---
_='foo[bar]'
foo=([bar]=([0]='') )
---8<---

The above, and a few more details were reported upstream at
http://lists.research.att.com/pipermail/ast-users/2014q4/004685.html

Here is a cut&paste of an off-list mail that should
make it easier to see the proposed patch is good:

---8<---
2014-12-12 13:23 GMT-02:00 David Korn <dgkorn>:
> Thanks for the report and the patch.  However, on the recent beta version
> 93v- 2014-09-29. I am not able to reproduce the bug (at least on ubuntu
> Linux).

  I will make an official RedHat bug report, as it looks like my patch is
good :) For earlier releases it is very unlikely to make a backport of
latest ksh, and usually should only pull patches if a problem is found.

> You can download this release from www.research.att.com/sw/download/beta/
> If you have the problem with this, let me know.

  Looks like I rediscovered the patch :) I downloaded the latest
sources and it has:

        if(fp || (value && value!=Empty))

my patch only had extra spaces:

-        if(fp || value)
+        if(fp || (value && value != Empty))

[...quoted email here...]

Thanks!
Paulo
---8<---

Comment 1 Paulo Andrade 2014-12-12 15:54:46 UTC
Created attachment 967695 [details]
ksh-20120801-array.patch

This patch is for rhel-7, but this is a one liner
that should be trivial to adapt, but should not
need any changes to apply to fedora or earlier rhel.

Comment 3 Michal Hlavinka 2014-12-12 16:30:28 UTC
reproducible

Comment 8 errata-xmlrpc 2015-07-22 06:56:25 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-1450.html