7 Bug-Reported-by: Karlheinz Nolte <kn@k-nolte.de>
8 Bug-Reference-ID: <20040801200058.GA3311@mars.home.k-nolte.de>
9 Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2004-08/msg00009.html
13 The following script triggers the segfault.
14 This was found by Costa Tsaousis the author of FireHOL.
17 "I think I have found the bug. The script bellow crashes at the
18 third echo (UNSET). It seems to be a problem of the "unset" BASH
19 function when erasing arrays. It leaves something behind so that if
20 the array just unset is referenced, it produces a segmentation fault.
21 According to the documentation the first and the third expansions
22 should be exactly the same."
26 *** ../bash-3.0/arrayfunc.c Fri Dec 19 00:03:09 2003
27 --- arrayfunc.c Sun Aug 1 20:43:00 2004
38 ! return (var == 0 || invisible_p (var)) ? (SHELL_VAR *)0 : var;
42 *** ../bash-3.0/subst.c Sun Jul 4 13:56:13 2004
43 --- subst.c Thu Aug 12 13:36:17 2004
48 ! else if ((v = find_variable (varname)) && array_p (v))
50 vtype = VT_ARRAYMEMBER;
54 ! else if ((v = find_variable (varname)) && (invisible_p (v) == 0) && array_p (v))
56 vtype = VT_ARRAYMEMBER;
58 *** ../bash-3.0/variables.c Sun Jul 4 13:57:26 2004
59 --- variables.c Wed Aug 4 15:28:04 2004
63 # if defined (DEBUGGER)
64 ! v = init_dynamic_array_var ("BASH_ARGC", get_self, null_array_assign, (att_invisible|att_noassign));
65 ! v = init_dynamic_array_var ("BASH_ARGV", get_self, null_array_assign, (att_invisible|att_noassign));
66 # endif /* DEBUGGER */
67 ! v = init_dynamic_array_var ("BASH_SOURCE", get_self, null_array_assign, (att_invisible|att_noassign));
68 ! v = init_dynamic_array_var ("BASH_LINENO", get_self, null_array_assign, (att_invisible|att_noassign));
73 # if defined (DEBUGGER)
74 ! v = init_dynamic_array_var ("BASH_ARGC", get_self, null_array_assign, att_noassign);
75 ! v = init_dynamic_array_var ("BASH_ARGV", get_self, null_array_assign, att_noassign);
76 # endif /* DEBUGGER */
77 ! v = init_dynamic_array_var ("BASH_SOURCE", get_self, null_array_assign, att_noassign);
78 ! v = init_dynamic_array_var ("BASH_LINENO", get_self, null_array_assign, att_noassign);
83 old_var = find_variable (name);
84 if (old_var && local_p (old_var) && old_var->context == variable_context)
87 was_tmpvar = old_var && tempvar_p (old_var);
89 old_var = find_variable (name);
90 if (old_var && local_p (old_var) && old_var->context == variable_context)
92 ! VUNSETATTR (old_var, att_invisible);
96 was_tmpvar = old_var && tempvar_p (old_var);
97 *** ../bash-3.0/pcomplete.c Thu Jan 8 10:36:17 2004
98 --- pcomplete.c Tue Aug 3 23:15:41 2004
102 v = convert_var_to_array (v);
103 v = assign_array_var_from_word_list (v, lwords);
105 + VUNSETATTR (v, att_invisible);
111 if (array_p (v) == 0)
112 v = convert_var_to_array (v);
114 + VUNSETATTR (v, att_invisible);
117 *** ../bash-3.0/array.c Thu May 6 08:24:13 2004
118 --- array.c Wed Aug 25 15:50:42 2004
121 array_dispose_element(new);
122 free(element_value(ae));
123 ! ae->value = savestring(v);
125 } else if (element_index(ae) > i) {
127 array_dispose_element(new);
128 free(element_value(ae));
129 ! ae->value = v ? savestring(v) : (char *)NULL;
131 } else if (element_index(ae) > i) {
133 *** ../bash-3.0/patchlevel.h Wed Aug 22 08:05:39 2001
134 --- patchlevel.h Thu Sep 2 15:04:32 2004
137 looks for to find the patch level (for the sccs version string). */
139 ! #define PATCHLEVEL 0
141 #endif /* _PATCHLEVEL_H_ */
143 looks for to find the patch level (for the sccs version string). */
145 ! #define PATCHLEVEL 1
147 #endif /* _PATCHLEVEL_H_ */
148 *** ../bash-3.0/tests/dbg-support.tests Tue Mar 25 15:33:03 2003
149 --- tests/dbg-support.tests Tue Aug 3 23:09:29 2004
152 trap 'print_return_trap $LINENO' RETURN
154 ! # Funcname is now an array. Vanilla Bash 2.05 doesn't have FUNCNAME array.
155 ! echo "FUNCNAME" ${FUNCNAME[0]}
157 # We should trace into the below.
159 trap 'print_return_trap $LINENO' RETURN
161 ! # Funcname is now an array, but you still can't see it outside a function
162 ! echo "FUNCNAME" ${FUNCNAME[0]:-main}
164 # We should trace into the below.