Simple test case:

/arch/linux.i386-64/bin/ksh -c 'typeset -T y_t=( compound ex=(i=1)) ;
y_t v ; [[ -v v.ex.l ]]'
./arch/linux.i386-64/bin/ksh: ex.l: is not an element of v

and

./arch/linux.i386-64/bin/ksh +nounset -c 'typeset -T y_t=( compound
ex=(i=1)) ; y_t v ; print "${v.ex.l}"'
./arch/linux.i386-64/bin/ksh: ex.l: is not an element of v

Both should not trigger an error message unless set -o nounset is set.
>From C api level these messages, whether set -o nounset is enabled or
not, should be suppressed with NV_NOADD|NV_NOFAIL, which does not
happen in ast-ksh 20120813 either.

Please have a look quickly at the problem. I am stuck.
Please.

Olga

On Sat, Aug 18, 2012 at 5:02 AM, ольга крыжановская
<olga.kryzhanov...@gmail.com> wrote:
> Analysis:
> gdb --args ./arch/linux.i386-64/bin/ksh -c 'builtin poll ; typeset -T
> p_t=( integer fd ; compound events revents ) ; function x { p_t -a
> xx.p=( [0]=( fd=0 events=( pollin=true ) revents=() ) ) ; poll -R -t10
> xx.p ; print -v xx ; } ; compound xx ; x'
> Reading symbols from
> /home/test001/work/ast_ksh_20120813/build_poll/arch/linux.i386-64/bin/ksh...done.
> (gdb) break write
> Breakpoint 1 at 0x40caa8
> (gdb) run
> Starting program:
> /home/test001/work/ast_ksh_20120813/build_poll/arch/linux.i386-64/bin/ksh
> -c builtin\ poll\ \;\ typeset\ -T\ p_t=\(\ integer\ fd\ \;\ compound\
> events\ revents\ \)\ \;\ function\ x\ \{\ p_t\ -a\ xx.p=\(\ \[0\]=\(\
> fd=0\ events=\(\ pollin=true\ \)\ revents=\(\)\ \)\ \)\ \;\ poll\ -R\
> -t10\ xx.p\ \;\ print\ -v\ xx\ \;\ \}\ \;\ compound\ xx\ \;\ x
>
> Breakpoint 1, 0x00007ffff74bb1c0 in write () from /lib64/libc.so.6
> (gdb) where
> #0  0x00007ffff74bb1c0 in write () from /lib64/libc.so.6
> #1  0x000000000050829d in sfwr (f=0x7d9fe0, buf=0x7ffff7fa8070, n=131,
> disc=0x0) at 
> /home/test001/work/ast_ksh_20120813/build_poll/src/lib/libast/sfio/sfwr.c:209
> #2  0x00000000004f29f6 in _sfflsbuf (f=0x7d9fe0, c=-1) at
> /home/test001/work/ast_ksh_20120813/build_poll/src/lib/libast/sfio/sfflsbuf.c:97
> #3  0x00000000004fcdf3 in sfsync (f=0x7d9fe0) at
> /home/test001/work/ast_ksh_20120813/build_poll/src/lib/libast/sfio/sfsync.c:133
> #4  0x00000000004bcc09 in errorv (id=0x0, level=3, ap=0x7fffffff8b08)
> at 
> /home/test001/work/ast_ksh_20120813/build_poll/src/lib/libast/misc/error.c:576
> #5  0x00000000004bd083 in errormsg (dictionary=0x55598e "libshell",
> level=3) at 
> /home/test001/work/ast_ksh_20120813/build_poll/src/lib/libast/misc/errormsg.c:38
> #6  0x00000000004145e5 in create_type (np=0x7ffff7fbcc80,
> name=0x7ffff7facac8 "events.pollin", flag=1441792, fp=0x7ffff7fbd050)
>     at 
> /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/nvtype.c:541
> #7  0x0000000000457de0 in create_tree (np=0x7ffff7fbcc80,
> name=0x7ffff7facac8 "events.pollin", flag=1441792, dp=0x7ffff7fbc210)
>     at 
> /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/nvtree.c:79
> #8  0x00000000004510d5 in nv_create (name=0x7ffff7facac0
> "xx.p[0].events.pollin", root=0x7ffff7fe2f80, flags=1441792,
> dp=0x7fffffff8db0)
>     at 
> /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/name.c:1192
> #9  0x0000000000451ca8 in nv_open (name=0x7fffffff8ec0
> "xx.p[0].events.pollin", root=0x7ffff7fbc8c0, flags=1441792)
>     at 
> /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/name.c:1404
> #10 0x000000000048f966 in nv_open_fmt (dict=0x7ffff7fbc8c0,
> flags=1441792, namefmt=0x56fc6f "%s[%s].events.%s")
>     at 
> /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/bltins/poll.c:235
> #11 0x000000000049037e in b_poll (argc=1, argv=0x7ffff7fbb738,
> context=0x7dc8b8) at
> /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/bltins/poll.c:538
> #12 0x0000000000474e59 in sh_exec (shp=0x7dc3a0, t=0x7ffff7fbb660,
> flags=4) at 
> /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/xec.c:1332
> #13 0x0000000000477cef in sh_exec (shp=0x7dc3a0, t=0x7ffff7fbb890,
> flags=7) at 
> /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/xec.c:2151
> #14 0x000000000047d8cf in sh_funscope_20120720 (shp=0x7dc3a0, argn=1,
> argv=0x7ffff7fac700, fun=0, arg=0x7fffffffcfe0, execflg=5)
>     at 
> /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/xec.c:3953
> #15 0x000000000047bab8 in sh_funct (shp=0x7dc3a0, np=0x7ffff7fbc010,
> argn=1, argv=0x7ffff7fac700, envlist=0x0, execflg=5)
>     at 
> /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/xec.c:3282
> #16 0x000000000047599b in sh_exec (shp=0x7dc3a0, t=0x7ffff7fac6a0,
> flags=5) at 
> /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/xec.c:1513
> #17 0x0000000000477d2a in sh_exec (shp=0x7dc3a0, t=0x7ffff7fac6a0,
> flags=5) at 
> /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/xec.c:2155
> #18 0x000000000040e93a in exfile (shp=0x7dc3a0, iop=0x7ffff7fb8d60,
> fno=-1) at 
> /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/main.c:581
> #19 0x000000000040db2b in sh_main (ac=3, av=0x7fffffffe108,
> userinit=0) at 
> /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/main.c:353
> #20 0x000000000040cd79 in main (argc=3, argv=0x7fffffffe108) at
> /home/test001/work/ast_ksh_20120813/build_poll/src/cmd/ksh93/sh/pmain.c:45
>
> create_type() fails, but in the wrong way: It uses
> 'errormsg(SH_DICT,ERROR_exit(1),e_notelem,n,name,nv_name(np));'
> instead of looking at flags and test for NV_NOFAIL and return NULL.
>
> I tried to fix the problem with this patch:
> diff -u5 src/cmd/ksh93/sh/nvtype.c src/cmd/ksh93/sh/nvtype.c
> --- src/cmd/ksh93/sh/nvtype.c 2012-08-07 23:13:31.000000000 +0200
> +++ src/cmd/ksh93/sh/nvtype.c   2012-08-18 03:13:19.479515490 +0200
> @@ -536,10 +536,12 @@
>                 if(name[n]!='=') for(i=0; i < dp->ndisc; i++)
>                 {
>                         if((memcmp(name,dp->names[i],n)==0) &&
> dp->names[i][n]==0)
>                                 return(nq);
>                 }
> +               if (flag & NV_NOFAIL)
> +                       return NULL;
>                 errormsg(SH_DICT,ERROR_exit(1),e_notelem,n,name,nv_name(np));
>         }
>         return(nq);
>  }
>
> However, the patch does not work, if the array has more than 1
> element, for example:
>
> echo | ./arch/linux.i386-64/bin/ksh -c 'builtin poll ; typeset -T
> p_t=( integer fd ; compound events revents ) ; function x { p_t -a
> xx.p=( [0]=( fd=0 events=( pollin=true ) revents=() ) [4]=( fd=0
> events=( pollin=true ) revents=() )) ; poll -R -t10 xx.p ; print -v xx
> ; } ; compound xx ; x'
> (
>         p_t -a p=(
>                 [0]=(
>                         typeset -l -i fd=0
>                 )
>                 [4]=(
>                         typeset -l -i fd=0
>                 )
>                 [0]=(
>                         events=(
>                                 pollin=true
>                         )
>                         revents=(
>                                 pollhup=true
>                                 pollin=true
>                         )
>                 )
>                 [4]=(
>                         events=(
>                                 pollin=true
>                         )
>                         revents=(
>                                 pollhup=true
>                                 pollin=true
>                         )
>                 )
>         )
> )
>
> I have no idea how to solve that. I am not sure why the code wants to
> call create_type() at all, because we have NV_NOADD set in the code.
>
> David, can you look, please?
>
> Olga
>
> On Sat, Aug 18, 2012 at 2:54 AM, ольга крыжановская
> <olga.kryzhanov...@gmail.com> wrote:
>> David, as clarification:
>> The poll(1) builtin is acting up for types. I think Roland's design
>> anticipates that it can not create new variables in a compound
>> variable which is embedded in a type. However ksh even acts up if some
>> one wants to *read* a compound variable member which does not exist.
>>
>> For example:
>> ksh -c 'typeset -T y_t=( compound ex=(i=1)) ; y_t v ; print "${v.ex.nono}"'
>> ./arch/linux.i386-64/bin/ksh: ex.nono: is not an element of v
>>
>> In poll(1) I get the same warning, despite the use of
>> NV_NOFAIL|NV_NOADD flags in the nv_open() call. I think the nv_open()
>> call should just fail silently, right?
>>
>> Olga
>>
>> On Sat, Aug 18, 2012 at 2:31 AM, ольга крыжановская
>> <olga.kryzhanov...@gmail.com> wrote:
>>> David, why do I get a 'x.sh: line 8: extensions.i: is not an element
>>> of x' for the script below?
>>>
>>> typeset -T y_t=(
>>>         compound extensions
>>> )
>>> y_t x;
>>> x.extensions=( integer i=1 )
>>> print "$x"
>>>
>>> This is rather a *big* problem since I assumed that compound variables
>>> are always extensible, and if I add an array of compound variables I
>>> can both add array elements and a variable number of data in these
>>> compound variables in the array.
>>>
>>> Olga
>>> --
>>>       ,   _                                    _   ,
>>>      { \/`o;====-    Olga Kryzhanovska   -====;o`\/ }
>>> .----'-/`-/     olga.kryzhanov...@gmail.com   \-`\-'----.
>>>  `'-..-| /       http://twitter.com/fleyta     \ |-..-'`
>>>       /\/\     Solaris/BSD//C/C++ programmer   /\/\
>>>       `--`                                      `--`
>>
>>
>>
>> --
>>       ,   _                                    _   ,
>>      { \/`o;====-    Olga Kryzhanovska   -====;o`\/ }
>> .----'-/`-/     olga.kryzhanov...@gmail.com   \-`\-'----.
>>  `'-..-| /       http://twitter.com/fleyta     \ |-..-'`
>>       /\/\     Solaris/BSD//C/C++ programmer   /\/\
>>       `--`                                      `--`
>
>
>
> --
>       ,   _                                    _   ,
>      { \/`o;====-    Olga Kryzhanovska   -====;o`\/ }
> .----'-/`-/     olga.kryzhanov...@gmail.com   \-`\-'----.
>  `'-..-| /       http://twitter.com/fleyta     \ |-..-'`
>       /\/\     Solaris/BSD//C/C++ programmer   /\/\
>       `--`                                      `--`



-- 
      ,   _                                    _   ,
     { \/`o;====-    Olga Kryzhanovska   -====;o`\/ }
.----'-/`-/     olga.kryzhanov...@gmail.com   \-`\-'----.
 `'-..-| /       http://twitter.com/fleyta     \ |-..-'`
      /\/\     Solaris/BSD//C/C++ programmer   /\/\
      `--`                                      `--`

_______________________________________________
ast-developers mailing list
ast-developers@research.att.com
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to