Path: csiph.com!xmission!news.glorb.com!usenet.stanford.edu!not-for-mail From: Sergey Tselikh Newsgroups: gnu.bash.bug Subject: bash-4.3_p39 Segfaults in array_flush at array.c:111 after incorrect conversion from indexed to associative array Date: Sun, 16 Aug 2015 11:02:35 +1000 Lines: 69 Approved: bug-bash@gnu.org Message-ID: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: usenet.stanford.edu 1439699203 17463 208.118.235.17 (16 Aug 2015 04:26:43 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mime-version:content-type :content-transfer-encoding; bh=w5QknkfTKRxmhqv523yCZhFqxjNW/WH3Lhl38Ax3Cds=; b=KiZYRcCjwQx8nekcJYGlkfbfBzREWtxiMp7c42lh67A0z3Vw9aZtOfMl448/HkZyXA SapcFDBV20dikSw1gF9viY81H1zrXvI8Axmq/tMSxwrxSP0xMiTYOm3u0ANDVM19G246 ydo3q08jN+kiF9Xfw555EgY3zQ02kdOSM/SFngGXcpUuQzr+CXAJBBUZHNz2rhUfpste EUUpnBpF8vhH++57KPk/bvFn9kUIRAguTmcjvGWvsexIkpO/m0boBUHoNAiAxO2ArAuh eJmF3G/YmXZzssU8r/ploH5AySPX/0uj0nnHCsKZ3lodYxPnjUVcAr6+l++eq0pxUImH ZWKg== X-Received: by 10.152.25.133 with SMTP id c5mr30066563lag.120.1439687011825; Sat, 15 Aug 2015 18:03:31 -0700 (PDT) X-Mailer: Sylpheed 3.4.2 (GTK+ 2.24.27; x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::233 X-Mailman-Approved-At: Sun, 16 Aug 2015 00:26:41 -0400 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:11353 Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: x86_64-pc-linux-gnu-gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I./include -I. -I./include -I./lib -DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' -DSTANDARD_UTILS_PATH='/bin:/usr/bin:/sbin:/usr/sbin' -DSYS_BASHRC='/etc/bash/bashrc' -DSYS_BASH_LOGOUT='/etc/bash/bash_logout' -DNON_INTERACTIVE_LOGIN_SHELLS -DSSH_SOURCE_BASHRC -pipe -march=corei7-avx -mno-aes -mfpmath=sse,387 -O2 -finline-functions -fomit-frame-pointer uname output: Linux laptop 3.10.77-gentoo-stselikh #1 SMP PREEMPT Mon May 18 12:45:11 VLAT 2015 x86_64 Intel(R) Core(TM) i3-2310M CPU @ 2.10GHz GenuineIntel GNU/Linux Machine Type: x86_64-pc-linux-gnu Bash Version: 4.3 Patch Level: 39 Release Status: release Configuration Information of bash-4.3_p39 recompiled with debug information [Automatically generated by bashbug, of course]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu' -DCONF_VENDOR='unknown' -DLOCALEDIR='/home/stselikh/untars/bash-43-39/bash-4.3/root/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -g uname output: Linux laptop 3.10.77-gentoo-stselikh #1 SMP PREEMPT Mon May 18 12:45:11 VLAT 2015 x86_64 Intel(R) Core(TM) i3-2310M CPU @ 2.10GHz GenuineIntel GNU/Linux Machine Type: x86_64-unknown-linux-gnu Bash Version: 4.3 Patch Level: 39 Release Status: release Description: An incorrect conversion from indexed to associative array in bash script leads bash interpreter to segfault (bash still gives a useful error report in this situation, which is good). As seen in the output of GDB, bash terminates in array_flush function: Core was generated by `../untars/bash-43-39/bash-4.3/root/bin/bash -x repro'. Program terminated with signal SIGSEGV, Segmentation fault. #0 0x0000000000470879 in array_flush (a=0x19de728) at array.c:111 111 for (r = element_forw(a->head); r != a->head; ) { Repeat-By: The following script may be used to repeat the problem: #!/bin/bash aaa() { declare -g -a unique=() } bbb() { declare -g -A unique=() } aaa bbb When run with -x, it gives the following output: + aaa + unique=() + declare -g -a unique + bbb repro: line 8: bbb: unique: cannot convert indexed to associative array + unique=() Segmentation fault (core dumped) -- Sergey Tselikh