[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: array subscripts act differently for integers(ie. let)
From: |
Eduardo A . Bustamante López |
Subject: |
Re: array subscripts act differently for integers(ie. let) |
Date: |
Wed, 18 Feb 2015 18:57:31 -0600 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Wed, Feb 18, 2015 at 10:14:10PM +0100, emanuelczirai@cryptolab.net wrote:
> That segfault though:
I confirm that the segmentation fault is in the latest devel version.
dualbus@dualbus ~ % gdb
GNU gdb (GDB) 7.4.1-debian
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) file /tmp/bash-devel
Reading symbols from /tmp/bash-devel...done.
(gdb) r poc
Starting program: /tmp/bash-devel poc
+ declare -A ar
+ key='`echo -n "1">>times.txt`'
+ (( ++ar[`echo -n "1">>times.txt`] ))
++ echo -n 1
poc: line 4: ar: bad array subscript
++ echo -n 1
poc: line 4: ar[`echo -n "1">>times.txt`]: bad array subscript
Program received signal SIGSEGV, Segmentation fault.
bind_int_variable (lhs=0x7b8f08 "ar[`echo -n \"1\">>times.txt`]", rhs=0x7b32f8
"1") at variables.c:2878
warning: Source file is more recent than executable.
2878
(gdb) bt
#0 bind_int_variable (lhs=0x7b8f08 "ar[`echo -n \"1\">>times.txt`]",
rhs=0x7b32f8 "1") at variables.c:2878
#1 0x000000000044e901 in expr_bind_variable (lhs=0x7b8f08 "ar[`echo -n
\"1\">>times.txt`]", rhs=0x7b32f8 "1") at expr.c:317
#2 0x000000000044f984 in exp0 () at expr.c:987
#3 0x000000000044f89f in exp1 () at expr.c:955
#4 0x000000000044f790 in exppower () at expr.c:910
#5 0x000000000044f58a in exp2 () at expr.c:835
#6 0x000000000044f51f in exp3 () at expr.c:809
#7 0x000000000044f4b0 in expshift () at expr.c:785
#8 0x000000000044f403 in exp4 () at expr.c:755
#9 0x000000000044f38c in exp5 () at expr.c:733
#10 0x000000000044f34a in expband () at expr.c:715
#11 0x000000000044f30c in expbxor () at expr.c:696
#12 0x000000000044f2ce in expbor () at expr.c:677
#13 0x000000000044f23f in expland () at expr.c:650
#14 0x000000000044f1ac in explor () at expr.c:622
#15 0x000000000044f075 in expcond () at expr.c:578
#16 0x000000000044ed3c in expassign () at expr.c:466
#17 0x000000000044ed07 in expcomma () at expr.c:446
#18 0x000000000044ec84 in subexpr (expr=0x7b9d88 "++ar[`echo -n
\"1\">>times.txt`]") at expr.c:428
#19 0x000000000044eb1c in evalexp (expr=0x7b9d88 "++ar[`echo -n
\"1\">>times.txt`]", validp=0x7fffffffdd6c) at expr.c:393
#20 0x00000000004403c4 in execute_arith_command (arith_command=0x7b9a48) at
execute_cmd.c:3561
#21 0x000000000043bc18 in execute_command_internal (command=0x7b8d88,
asynchronous=0, pipe_in=-1, pipe_out=-1, fds_to_close=0x7b8e68) at
execute_cmd.c:995
#22 0x000000000043add0 in execute_command (command=0x7b8d88) at
execute_cmd.c:416
#23 0x00000000004263dd in reader_loop () at eval.c:163
#24 0x000000000042412b in main (argc=2, argv=0x7fffffffdfe8,
env=0x7fffffffe000) at shell.c:757
(gdb) info locals
v = 0x0
isint = 0
isarr = 1
implicitarray = 0
(gdb) l
2873 else
2874 INVALIDATE_EXPORTSTR (entry);
2875
2876 if (var_isset (entry))
2877 dispose_command (function_cell (entry));
2878
2879 if (value)
2880 var_setfunc (entry, copy_command (value));
2881 else
2882 var_setfunc (entry, 0);
This patch seems to fix it:
dualbus@dualbus ~/local/src/bash
% git log -p -1|cat
commit 5d29a37a60c9daabf85de66dd7df3c459bd0c468
Author: Eduardo A. Bustamante López <dualbus@gmail.com>
Date: Wed Feb 18 18:53:04 2015 -0600
Check if v is not NUL
diff --git a/variables.c b/variables.c
index 2f07ebb..91912cd 100644
--- a/variables.c
+++ b/variables.c
@@ -2875,6 +2875,7 @@ bind_int_variable (lhs, rhs)
if (v && isint)
VSETATTR (v, att_integer);
+ if (v)
VUNSETATTR (v, att_invisible);
return (v);
Re: array subscripts act differently for integers(ie. let), Eduardo A . Bustamante López, 2015/02/16