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

getjobtext() gives invalid utf8, leading to segfault



With the powerlevel10k prompt, running either of these two commands
causes the shell to segfault:
    $ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA月光
    $ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA月
The AAAs can be replaced with anything as long as the length is
unchanged (did not test with non-ascii though). Changing the kanji at
the end usually makes it not crash, strangely enough.

A minimal zshrc creating the same crash is
    _preexec() {
        [[ $2 == "" ]]
    }
    preexec_functions=(_preexec)

If we echo $2 instead of comparing it, it is printed as
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA月�
hinting that it's a multibyte error. Curiously, /bin/echo instead
gives 月元 at the end.

Looking through the source, it looks like this string is created by
getjobtext(). This hints that similar errors might be seen in other
places where jobs are displayed, and indeed:
    $ cat /dev/stdin
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA月
    ^Z
    zsh: suspended  cat /dev/stdin
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA會

I am running `zsh 5.8 (x86_64-pc-linux-gnu)`, the one that is current
packaged in Arch Linux.




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