bug-bash@gnu.org

2021-10-05 Thread Koichi Murase
I have questions on the new feature ${var/pat/&} in the devel branch. > commit f188aa6a013e89d421e39354086eed513652b492 (upstream/devel) > Author: Chet Ramey > Date: Mon Oct 4 15:30:21 2021 -0400 > > enable support for using `&' in the pattern substitution replacement > string > > Any unqu

[PATCH] devel: fix segfault by unset 'assoc[${x[0]}]'

2021-10-05 Thread Koichi Murase
Bash Version: devel branch (441078402919f6f0dd677cad18d55c7a89d294fc), 5.1.8(2)-maint (x86_64-pc-linux-gnu) Description: In the devel branch, « unset 'assoc[${x[0]}]' » causes a segmentation fault, where `assoc' is the name of an associative array. This does not happen with Bash 5.1.

Re: [PATCH] devel: fix segfault by unset 'assoc[${x[0]}]'

2021-10-05 Thread Koichi Murase
> In Bash 4.0--5.3, the unset command causes the following error: > > bash-4.0: [${x[0]}]: bad array subscript Sorry, please ignore these two lines. This part is unrelated to the fix of the patches. The above error message was produced for the empty associative array key, which is the expect

Re: Using systemd-249's libnss_systemd.so.2 triggers a crash in bash-5.1's malloc.c

2021-10-05 Thread Dominique Martinet
Chet Ramey wrote on Mon, Oct 04, 2021 at 10:11:10PM -0400: > > I'm running busybox sh in a unit (which starts properly), then > > interactively test things from there. > > > > Running in gdb does fail the same way as running normally, so I've also > > been looking at that a bit, but nothing obviou

Re: [PATCH] devel: fix segfault by unset 'assoc[${x[0]}]'

2021-10-05 Thread Chet Ramey
On 10/5/21 7:05 AM, Koichi Murase wrote: > The segmentation fault is fixed by the above patch, but there > still remains the same error as bash 4.4. > > bash-patch1: ${x[0: bad substitution > > This is caused by an inconsistency between `valid_array_reference > (name,flags)' (arrayfu

Re: Using systemd-249's libnss_systemd.so.2 triggers a crash in bash-5.1's malloc.c

2021-10-05 Thread Chet Ramey
On 10/5/21 1:50 PM, Dominique Martinet wrote: > Turns out I'm lucky enough on address consistency.. > > So, > - since we have a nice before/after with systemd, I took a moment to > bisect it. > It comes down to this commit[1] which is basically using > malloc_usable_size() to use buffers beyond

Re: Using systemd-249's libnss_systemd.so.2 triggers a crash in bash-5.1's malloc.c

2021-10-05 Thread Chet Ramey
On 10/5/21 1:50 PM, Dominique Martinet wrote: > If I change malloc_usable_size to return p->mh_nbytes instead of > maxbytes, then the crash disappears.[2] > > I did not read the full bash malloc code but I suspect the buffer really > could be grown, but we would need to fix p->mh_nbytes to maxbyt

Incorrect LINENO with exported nested functions with loops

2021-10-05 Thread Tom Coleman
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-redhat-linux-gnu' -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -

Re: [PATCH] devel: fix segfault by unset 'assoc[${x[0]}]'

2021-10-05 Thread Koichi Murase
> The difference is that valid_array_reference can be called before > any of the subscript is expanded, in which case you need to parse > things that can be expanded, where unbind_array_element is called > after all the expansions are performed (but see below). > > So let's see if we can talk throu

[PATCH] 4.0..devel: fix a problem that unset 'a[`echo 0`]' causes "bad array subscript" error

2021-10-05 Thread Koichi Murase
[ I initially intended to submit this report after the previous report at https://lists.gnu.org/archive/html/bug-bash/2021-10/msg00051.html has been settled. I decided to submit this patch now because a problem related to this report is mentioned in the above thread. Note that this patch bases on