On Fri, Aug 9, 2013 at 1:14 AM, Roland Mainz <[email protected]> wrote:
> On Thu, Aug 8, 2013 at 11:40 PM, Cedric Blancher
> <[email protected]> wrote:
>> ksh (ast-ksh.20130807) crashes on my Fedora laptop if I try to copy
>> the information in .sh.sig to an array for later use:
>>
>> ksh -c 'compound c ; compound -a c.car; integer c.cari=0; trap
>> "typeset -c c.car[\$((c.cari++))]=.sh.sig" USR1; kill -q4 -s USR1 $$;
>> kill -q5 -s USR1 $$; true ; print -v c'
>> Segmentation fault
>>
>> (I don't have a usable stack trace because this is an optimized build.
>> Roland, could to have a look please?)
>
> The following variation of Cedric's testcase doesn't crash but doesn't
> print the correct .sh.sig data either:
> -- snip --
> $ cat test1.sh
> compound c
> compound -a c.car
> integer c.cari=0
> integer trap_i
>
> trap '(( trap_i=c.cari++ )) ; typeset -c "c.car[$trap_i]=.sh.sig"' USR1
>
> kill -q4 -s USR1 $$
> kill -q5 -s USR1 $$
> true
> print -v c
> $ ./arch/linux.i386-64/bin/ksh -x test1.sh
> + typeset -C c
> + typeset -C -a c.car
> + c.cari=0
> + typeset -li c.cari
> + typeset -li trap_i
> + trap '(( trap_i=c.cari++ )) ; typeset -c "c.car[$trap_i]=.sh.sig"' USR1
> + kill -q4 -s USR1 55344
> + (( trap_i=c.cari++ ))
> + typeset -c 'c.car[0]=.sh.sig'
> + kill -q5 -s USR1 55344
> + (( trap_i=c.cari++ ))
> + typeset -c 'c.car[1]=.sh.sig'
> + true
> + print -v c
> (
>         typeset -C -a car=(
>                 (
>                 )
>                 (
>                 )
>         )
>         typeset -l -i cari=2
> )
> -- snip --
>
> Grumpf... ;-(

Exactly the noise I would make in this situation. However, while cool,
.sh.sig is a new feature.

If you'd run the testcase with VMALLOC_OPTIONS=abort on Solaris 11 you
would've noticed that all copied data are zero'ed (testcase below).
My theory is that car[i]=.sh.sig copies the nv objects, including the
pointers to values, but the pointers still point to the siginfo data
and the data themselves are NOT copied as they should be:
VMALLOC_OPTIONS=abort ~/bin/ksh -c 'compound -a car ; integer i cari=0
; trap "(( i=cari++ )) ; car[i]=.sh.sig" USR1 USR2
; kill -q5 -s USR1 $$ ; kill -q19 -s USR2 $$ ; print -v car'
(
        (
                typeset -r -l -i 16 addr=16#0
                typeset -r -l -i band=0
                typeset -r code=QUEUE
                typeset -r -i errno=0
                typeset -r name=USR2
                typeset -r -i pid=0
                typeset -r -i signo=0
                typeset -r -i status=0
                typeset -r -i uid=0
                value=(
                        typeset -r -i int=0
                        typeset -r -l -i 16 ptr=16#0
                )
        )
        (
                typeset -r -l -i 16 addr=16#0
                typeset -r -l -i band=0
                typeset -r code=QUEUE
                typeset -r -i errno=0
                typeset -r name=USR2
                typeset -r -i pid=0
                typeset -r -i signo=0
                typeset -r -i status=0
                typeset -r -i uid=0
                value=(
                        typeset -r -i int=0
                        typeset -r -l -i 16 ptr=16#0
                )
        )
)

Irek
_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers

Reply via email to