On Fri, Jun 16, 2023 at 10:59:24AM -0400, Lawrence Velázquez wrote: > % /bin/bash -c 'foo= declare -ax foo' > zsh: segmentation fault /bin/bash -c 'foo= declare -ax foo' > > I am seeing this behavior with bash 3.2.57, so it appears to be > longstanding.
I get a segfault/core dump in every version of bash starting from 2.05b, which is the oldest I've got. In case this helps, here's the backtrace from the core from bash 5.2: (gdb) bt #0 0x00005582fea45845 in array_insert (a=0x558300ae61b0, i=i@entry=0, v=v@entry=0x558300ae6070 "") at array.c:574 #1 0x00005582fea12d3a in bind_variable_internal (name=0x558300ae60f0 "foo", value=0x558300ae6130 "", table=table@entry=0x558300ac3cd0, hflags=hflags@entry=0, aflags=aflags@entry=544) at variables.c:3231 #2 0x00005582fea13d2a in push_temp_var (data=0x558300ae7110) at variables.c:4625 #3 0x00005582fea3d093 in hash_flush (table=table@entry=0x558300ae7290, free_data=free_data@entry=0x5582fea13e90 <propagate_temp_var>) at hashlib.c:395 #4 0x00005582fea178e8 in dispose_temporary_env ( pushf=pushf@entry=0x5582fea13e90 <propagate_temp_var>) at variables.c:4690 #5 0x00005582fea1797a in dispose_used_env_vars () at variables.c:4710 #6 0x00005582fea0afb9 in execute_command_internal (command=0x558300ae37d0, asynchronous=asynchronous@entry=0, pipe_in=pipe_in@entry=-1, pipe_out=pipe_out@entry=-1, fds_to_close=fds_to_close@entry=0x558300ae3a10) at execute_cmd.c:872 #7 0x00005582fea65c19 in parse_and_execute (string=<optimized out>, from_file=from_file@entry=0x5582feab50a7 "-c", flags=flags@entry=20) at evalstring.c:536 #8 0x00005582fe9f22a0 in run_one_command ( command=0x7ffd19e26aa0 "foo= declare -ax foo") at shell.c:1473 #9 0x00005582fe9f0aab in main (argc=3, argv=0x7ffd19e26628, env=0x7ffd19e26648) at shell.c:763