Discussion:
[ast-developers] Copying multidimensional bool array results in crash...
Roland Mainz
2013-07-25 00:05:23 UTC
Permalink
Hi!

----

While resuming work on the testsuite module for typeset -c I hit this
crash with ast-ksh.2013-07-19 on SuSE 12.3/AMD64/64bit:
-- snip --
$ gdb --args ~/bin/ksh -c 'function f { compound c=(bool -a a=(
[1][0][0]=true [1][1][1]=true ) ) ; typeset -c cp=c.a ; print -v cp ;
}; f'
[snip]
(gdb) run
Starting program: /home/test001/bin/ksh -c function\ f\ \{\ compound\
c=\(bool\ -a\ a=\(\ \[1\]\[0\]\[0\]=true\ \[1\]\[1\]\[1\]=true\ \)\
\)\ \;\ typeset\ -c\ cp=c.a\ \;\ print\ -v\ cp\ \;\ \}\;\ f

Program received signal SIGSEGV, Segmentation fault.
0x00000000004a6c7e in nv_nextsub (np=0x7ffff7f2fda0) at
/home/test001/work/ast_ksh_20130719/build_i386_64bit_debug/src/cmd/ksh93/sh/array.c:1198
1198 if(nv_isarray(mp))
(gdb) where
#0 0x00000000004a6c7e in nv_nextsub (np=0x7ffff7f2fda0) at
/home/test001/work/ast_ksh_20130719/build_i386_64bit_debug/src/cmd/ksh93/sh/array.c:1198
#1 0x00000000004a6f43 in nv_putsub_20120720 (np=0x7ffff7f2fda0,
sp=0x0, size=0, flags=8388608)
at /home/test001/work/ast_ksh_20130719/build_i386_64bit_debug/src/cmd/ksh93/sh/array.c:1284
#2 0x00000000004a6ccd in nv_nextsub (np=0x7ffff7f2fce0) at
/home/test001/work/ast_ksh_20130719/build_i386_64bit_debug/src/cmd/ksh93/sh/array.c:1202
#3 0x00000000004a6f43 in nv_putsub_20120720 (np=0x7ffff7f2fce0,
sp=0x0, size=0, flags=8388608)
at /home/test001/work/ast_ksh_20130719/build_i386_64bit_debug/src/cmd/ksh93/sh/array.c:1284
#4 0x00000000004a6ccd in nv_nextsub (np=0x7ffff7f2fc20) at
/home/test001/work/ast_ksh_20130719/build_i386_64bit_debug/src/cmd/ksh93/sh/array.c:1202
#5 0x00000000004a6f43 in nv_putsub_20120720 (np=0x7ffff7f2fc20,
sp=0x0, size=0, flags=8388608)
at /home/test001/work/ast_ksh_20130719/build_i386_64bit_debug/src/cmd/ksh93/sh/array.c:1284
#6 0x000000000044b8db in nv_outnode (np=0x7ffff7f2fc20, out=0x801fe0
<_Sfstdout>, indent=0, special=0)
at /home/test001/work/ast_ksh_20130719/build_i386_64bit_debug/src/cmd/ksh93/sh/nvtree.c:630
#7 0x0000000000486f99 in fmtbase64 (shp=0x804260 <sh>, iop=0x801fe0
<_Sfstdout>, string=0x7ffff7f2f131 "cp", fmt=0x0, alt=0)
at /home/test001/work/ast_ksh_20130719/build_i386_64bit_debug/src/cmd/ksh93/bltins/print.c:606
#8 0x000000000048639a in b_print (argc=3, argv=0x7ffff7f2f1e8,
context=0x8047b8 <sh+1368>)
at /home/test001/work/ast_ksh_20130719/build_i386_64bit_debug/src/cmd/ksh93/bltins/print.c:340
#9 0x000000000046906d in sh_exec (shp=0x804260 <sh>,
t=0x7ffff7f2f0c0, flags=7) at
/home/test001/work/ast_ksh_20130719/build_i386_64bit_debug/src/cmd/ksh93/sh/xec.c:1358
#10 0x000000000046c14e in sh_exec (shp=0x804260 <sh>,
t=0x7ffff7f2f0c0, flags=7) at
/home/test001/work/ast_ksh_20130719/build_i386_64bit_debug/src/cmd/ksh93/sh/xec.c:2225
#11 0x0000000000471ecd in sh_funscope_20120720 (shp=0x804260 <sh>,
argn=1, argv=0x7ffff7f1c930, fun=0x0, arg=0x7fffffffd330, execflg=5)
at /home/test001/work/ast_ksh_20130719/build_i386_64bit_debug/src/cmd/ksh93/sh/xec.c:4038
#12 0x00000000004700b4 in sh_funct (shp=0x804260 <sh>,
np=0x7ffff7ee2880, argn=1, argv=0x7ffff7f1c930, envlist=0x0,
execflg=5)
at /home/test001/work/ast_ksh_20130719/build_i386_64bit_debug/src/cmd/ksh93/sh/xec.c:3374
#13 0x0000000000469b91 in sh_exec (shp=0x804260 <sh>,
t=0x7ffff7f1c8d0, flags=5) at
/home/test001/work/ast_ksh_20130719/build_i386_64bit_debug/src/cmd/ksh93/sh/xec.c:1557
#14 0x000000000046c14e in sh_exec (shp=0x804260 <sh>,
t=0x7ffff7f1c8d0, flags=5) at
/home/test001/work/ast_ksh_20130719/build_i386_64bit_debug/src/cmd/ksh93/sh/xec.c:2225
#15 0x000000000040f502 in exfile (shp=0x804260 <sh>,
iop=0x7ffff7ee04d0, fno=-1) at
/home/test001/work/ast_ksh_20130719/build_i386_64bit_debug/src/cmd/ksh93/sh/main.c:603
#16 0x000000000040e74d in sh_main (ac=3, av=0x7fffffffe1f8,
userinit=0x0) at
/home/test001/work/ast_ksh_20130719/build_i386_64bit_debug/src/cmd/ksh93/sh/main.c:375
#17 0x000000000040d921 in main (argc=3, argv=0x7fffffffe1f8) at
/home/test001/work/ast_ksh_20130719/build_i386_64bit_debug/src/cmd/ksh93/sh/pmain.c:45
(gdb) print mp
$1 = (Namval_t *) 0x1
-- snip --

AFAIK the expected output would look like this:
-- snip --
(
[1]=(
(
true
)
(
[1]=true
)
)
)
-- snip --

----

Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
Roland Mainz
2013-07-25 00:07:29 UTC
Permalink
Post by Roland Mainz
While resuming work on the testsuite module for typeset -c I hit this
-- snip --
$ gdb --args ~/bin/ksh -c 'function f { compound c=(bool -a a=(
[1][0][0]=true [1][1][1]=true ) ) ; typeset -c cp=c.a ; print -v cp ;
}; f'
[snip]
Mhhh... the test doesn't even require typeset -c ... just copying a
compound variable is sufficient:
-- snip --
$ ksh -c 'function f { compound c=(bool -a a=( [1][0][0]=true
[1][1][1]=true ) ) ; compound x=c ; print -v x ; }; f'
Segmentation fault
-- snip --

----

Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
Loading...