Hi!
----
Attached (as "ksh_valgrind_arith_sh_compound_var_arithmetic_failed.sh.txt")
is a test script (derived from the "arith.sh" test module) which fails
when running ast-ksh.2012-05-18 on SuSE 12.1/AMD64 under valgrind
control like this:
-- snip --
$ valgrind --trace-children=yes --log-file=/dev/null ksh xxx.sh
compound var arithmetic failed, expected '( bar=2 baz=3 foo=1 )', got ''
compound var arithmetic failed, expected '( faz=0 )', got ''
compound var arithmetic failed, expected '( foz=777 )', got ''
compound var arithmetic failed, expected '( foz=777 )', got ''
compound var arithmetic failed, expected '( fuz=777 )', got ''
compound var arithmetic failed, expected 0, got ''
compound var arithmetic failed, expected 0, got ''
-- snip --
Note that "valgrind" does not report any hits... the example uses
--log-file=/dev/null only to avoid noise in this example.
I assume this is a bug (and not something caused by valgrinds
interference with fd usage) because if I change the script and
uncomment the line containing the '#force_subshell_fork="ulimit -c 0"'
(the use of "ulimit -c 0" in a subshell will trigger a |fork()| to
make sure this subshell really runs in a seperate process (this is
neccesary since calls to "ulimit" can't be undone)) the script works.
----
Bye,
Roland
--
__ . . __
(o.\ \/ /.o) [email protected]
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
cat > ./myscript <<-\!
tests=$*
typeset -A blop
function blop.get
{
.sh.value=777
}
function mkobj
{
nameref obj=$1
obj=()
[[ $tests == *1* ]] && {
(( obj.foo = 1 ))
(( obj.bar = 2 ))
(( obj.baz = obj.foo + obj.bar )) # ok
echo $obj
}
[[ $tests == *2* ]] && {
(( obj.faz = faz = obj.foo + obj.bar )) # ok
echo $obj
}
[[ $tests == *3* ]] && {
# case 3, 'active' variable involved, w/ intermediate variable
(( obj.foz = foz = ${blop[1]} )) # coredump
echo $obj
}
[[ $tests == *4* ]] && {
# case 4, 'active' variable, in two steps
(( foz = ${blop[1]} )) # ok
(( obj.foz = foz )) # ok
echo $obj
}
[[ $tests == *5* ]] && {
# case 5, 'active' variable involved, w/o intermediate variable
(( obj.fuz = ${blop[1]} )) # coredump
echo $obj
}
[[ $tests == *6* ]] && {
echo $(( obj.baz = obj.foo + obj.bar )) # coredump
}
[[ $tests == *7* ]] && {
echo $(( obj.foo + obj.bar )) # coredump
}
}
mkobj bla
!
chmod +x ./myscript
#force_subshell_fork="ulimit -c 0"
out="$(${force_subshell_fork} ; ./myscript 1)" ; exp='( bar=2 baz=3 foo=1 )' ;
[[ "${out}" != "${exp}" ]] && printf 'compound var arithmetic failed, expected
%q, got %q\n' "${exp}" "${out}"
out="$(${force_subshell_fork} ; ./myscript 2)" ; exp='( faz=0 )' ;
[[ "${out}" != "${exp}" ]] && printf 'compound var arithmetic failed, expected
%q, got %q\n' "${exp}" "${out}"
out="$(${force_subshell_fork} ; ./myscript 3)" ; exp='( foz=777 )' ;
[[ "${out}" != "${exp}" ]] && printf 'compound var arithmetic failed, expected
%q, got %q\n' "${exp}" "${out}"
out="$(${force_subshell_fork} ; ./myscript 4)" ; exp='( foz=777 )' ;
[[ "${out}" != "${exp}" ]] && printf 'compound var arithmetic failed, expected
%q, got %q\n' "${exp}" "${out}"
out="$(${force_subshell_fork} ; ./myscript 5)" ; exp='( fuz=777 )' ;
[[ "${out}" != "${exp}" ]] && printf 'compound var arithmetic failed, expected
%q, got %q\n' "${exp}" "${out}"
out="$(${force_subshell_fork} ; ./myscript 6)" ; exp='0' ;
[[ "${out}" != "${exp}" ]] && printf 'compound var arithmetic failed, expected
%q, got %q\n' "${exp}" "${out}"
out="$(${force_subshell_fork} ; ./myscript 7)" ; exp='0' ;
[[ "${out}" != "${exp}" ]] && printf 'compound var arithmetic failed, expected
%q, got %q\n' "${exp}" "${out}"
_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers