Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[BUG] Crash related to alias completion in arithmetic construct



A co-worker was trying to perform a calculation using a bunch of nested command
substitutions within an arithmetic construct and he reported to me that the
shell segfaulted on him. He waited a day or two to tell me about it, and i guess
his history was lost, so i'm still trying to piece together what he was actually
doing, but i think i found possibly two issues.

If i can narrow down the original problem he was having i'll send another
report, but here's one that i encountered by accident during troubleshooting:

  # OK
  % echo $(( $(foo)^D

  # OK
  % alias foo=:
  % echo $(( $(foo)^D

  # Crash
  % alias foo=': -x'
  % echo $(( $(foo)^D
  zsh: segmentation fault

I replicated this on 5.4.2 (Linux) and master (macOS). The ^D here is trying to
list completion possibilities, so you need the requisite set-up for that.

Back-trace from 5.4.2:

#0  hrealloc (p=0x562a558d31c0 " \205\210foo: Й\231U*V", old=8, new=new@entry=16) at ../../Src/mem.c:726
        h = <optimized out>
        ph = <optimized out>
#1  0x0000562a54b2b663 in zshlex_raw_add (c=c@entry=32) at ../../Src/lex.c:1937
        newbsiz = 16
#2  0x0000562a54b20f5a in ingetc () at ../../Src/input.c:232
        lastc = 32
#3  0x0000562a54b29069 in gettokstr (c=c@entry=58, sub=sub@entry=0) at ../../Src/lex.c:1380
        act = <optimized out>
        e = <optimized out>
        inbl = <optimized out>
        bct = <optimized out>
        pct = 0
        brct = 0
        seen_brct = 0
        fdpar = 0
        intpos = 1
        in_brace_param = 0
        inquote = <optimized out>
        unmatched = 0
        peek = STRING
#4  0x0000562a54b2a9e4 in gettok () at ../../Src/lex.c:908
        c = 58
        d = <optimized out>
        peekfd = -1
        peek = <optimized out>
        c = <optimized out>
        d = <optimized out>
        peekfd = <optimized out>
        peek = <optimized out>
        e = <optimized out>

dana



Messages sorted by: Reverse Date, Date, Thread, Author