zsh-workers
 help / color / mirror / code / Atom feed
* Segfault in echoti with Cs and Ms caps
@ 2024-07-16 19:53 Ronan Pigott
  2024-08-05  4:18 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Ronan Pigott @ 2024-07-16 19:53 UTC (permalink / raw)
  To: zsh-workers

Hi zsh-workers,

The following reproduces a segfault in zsh when the Cs or Ms terminfo
capabilities are defined. These caps take 1 and 2 string parameters
respectively, but are not special cased in echoti like the others:

  $ print -rl Cs=${terminfo[Cs]//$'\e'/\\E} Ms=${terminfo[Ms]//$'\e'/\\E}
  Cs=\E]12;%p1%s\E\
  Ms=\E]52;%p1%s;%p2%s\E\

  $ echoti Cs 1 # SIGSEGV
  $ echoti Ms 1 # SIGSEGV

  $ cat gdb.txt # echoti Ms 1
  #0  __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:76
  #1  0x000074550cb6ed20 in tparam_internal (tps=0x62a5e7e69090, string=0x62a5e7e6b8ec "\033]52;%p1%s;%p2%s\033\\", data=0x7ffc4a5e3960) at ../ncurses/./tinfo/lib_tparm.c:853
  #2  tparm (string=string@entry=0x62a5e7e6b8ec "\033]52;%p1%s;%p2%s\033\\") at ../ncurses/./tinfo/lib_tparm.c:1178
  #3  0x000074550cbce36c in bin_echoti (name=<optimized out>, argv=0x74550cbdabd8, ops=<optimized out>, func=<optimized out>) at /usr/src/debug/zsh/zsh-5.9/Src/Modules/terminfo.c:123
  #4  0x000062a5b8baa163 in execbuiltin (args=<optimized out>, assigns=0x0, bn=<optimized out>) at /usr/src/debug/zsh/zsh-5.9/Src/builtin.c:506
  #5  0x000062a5b8bd17e6 in execcmd_exec (state=state@entry=0x7ffc4a5e5550, eparams=eparams@entry=0x7ffc4a5e5060, input=input@entry=0, output=output@entry=0, how=<optimized out>, how@entry=18, last1=<optimized out>, last1@entry=2, close_if_forked=<optimized out>) at /usr/src/debug/zsh/zsh-5.9/Src/exec.c:4148
  #6  0x000062a5b8bd22cf in execpline2 (state=state@entry=0x7ffc4a5e5550, pcode=pcode@entry=8067, how=how@entry=18, input=0, output=0, last1=last1@entry=0) at /usr/src/debug/zsh/zsh-5.9/Src/exec.c:1960
  #7  0x000062a5b8bd2714 in execpline (state=state@entry=0x7ffc4a5e5550, slcode=<optimized out>, how=how@entry=18, last1=last1@entry=0) at /usr/src/debug/zsh/zsh-5.9/Src/exec.c:1689
  #8  0x000062a5b8bd4646 in execlist (state=state@entry=0x7ffc4a5e5550, dont_change_job=dont_change_job@entry=0, exiting=exiting@entry=0) at /usr/src/debug/zsh/zsh-5.9/Src/exec.c:1444
  #9  0x000062a5b8bd4e3e in execode (p=0x74550cbda7e8, dont_change_job=0, exiting=0, context=0x62a5b8c5f43e "toplevel") at /usr/src/debug/zsh/zsh-5.9/Src/exec.c:1221
  #10 0x000062a5b8bf32af in loop (toplevel=toplevel@entry=1, justonce=justonce@entry=0) at /usr/src/debug/zsh/zsh-5.9/Src/init.c:212
  #11 0x000062a5b8bfae05 in zsh_main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/zsh/zsh-5.9/Src/init.c:1794
  #12 0x000062a5b8ba90de in main (argc=<optimized out>, argv=<optimized out>) at ./main.c:93

Cheers,

Ronan


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Segfault in echoti with Cs and Ms caps
  2024-07-16 19:53 Segfault in echoti with Cs and Ms caps Ronan Pigott
@ 2024-08-05  4:18 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2024-08-05  4:18 UTC (permalink / raw)
  To: Ronan Pigott; +Cc: zsh-workers

On Tue, Jul 16, 2024 at 12:54 PM Ronan Pigott <ronan@rjp.ie> wrote:
>
> The following reproduces a segfault in zsh when the Cs or Ms terminfo
> capabilities are defined. These caps take 1 and 2 string parameters
> respectively, but are not special cased in echoti like the others:

We need a better way to handle this.  The existing special case code
would (I think) work for Cs, but there's currently no provision for a
capability that takes two string arguments like Ms, and continuing to
add special cases for nonstandard capabilities is going to become
tedious.

Doc here, search for "xterm+tmux":
https://invisible-island.net/xterm/terminfo.html


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-08-05  4:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-16 19:53 Segfault in echoti with Cs and Ms caps Ronan Pigott
2024-08-05  4:18 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).