Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appending text to internal tty may cause vim to hang indefinitely #14621

Open
julio-b opened this issue Apr 22, 2024 · 1 comment
Open

Appending text to internal tty may cause vim to hang indefinitely #14621

julio-b opened this issue Apr 22, 2024 · 1 comment
Labels

Comments

@julio-b
Copy link
Contributor

julio-b commented Apr 22, 2024

Steps to reproduce

  1. This works as expected:
vim --clean -c'set bt=nofile | eval ["\e[32mtest\e[m", "\e[33mTEST\e[m"]->repeat(40)->setline(1)' -c 'exe "term NONE"| wincmd j | exe "w >>"..2->term_gettty()'

2024-04-22-220957_577x309_scrot

  1. Now repeat the same test with larger text:
vim --clean -c'set bt=nofile | eval ["\e[32mtest\e[m", "\e[33mTEST\e[m"]->repeat(2040)->setline(1)' -c 'exe "term NONE"| wincmd j | exe "w >>"..2->term_gettty()'

Vim completely freezes.

Expected behaviour

The text should be appended to the embedded terminal without errors.

Version of Vim

v9.1.0359

Environment

Terminal: kitty
$TERM: xterm-kitty
OS: Archlinux
shell: bash 5.2.26

Logs and stack traces

There are no logs or errors.
I tracked this as best as i could with gdb/strace, and i think vim hangs up in src/fileio.c:5758. The write syscall never returns for some reason.

Backtrace
#0  0x00007ffff7b741a4 in __GI___libc_write (fd=fd@entry=11, buf=buf@entry=0x555555c74590, 
    nbytes=nbytes@entry=8192) at ../sysdeps/unix/sysv/linux/write.c:26
#1  0x000055555563a8fb in write_eintr (fd=11, buf=buf@entry=0x555555c74590, 
    bufsize=bufsize@entry=8192) at fileio.c:5759
#2  0x00005555557e9a72 in buf_write_bytes (ip=ip@entry=0x7fffffffa870) at bufwrite.c:517
#3  0x00005555557ead1e in buf_write (buf=buf@entry=0x5555558f40d0, fname=<optimized out>, 
    fname@entry=0x555555c6fa30 "/dev/pts/5", sfname=<optimized out>, 
    sfname@entry=0x555555c6f9f4 "/dev/pts/5", start=1, end=<optimized out>, 
    eap=eap@entry=0x7fffffffae00, append=1, forceit=0, reset_changed=1, filtering=0)
    at bufwrite.c:2056
#4  0x0000555555612661 in do_write (eap=0x7fffffffae00) at ex_cmds.c:2093
#5  0x000055555562581e in do_one_cmd (cookie=0x0, fgetline=0x0, cstack=0x7fffffffafb0, 
    flags=3, cmdlinep=0x7fffffffad60) at ex_docmd.c:2620
#6  do_cmdline (cmdline=<optimized out>, fgetline=0x0, cookie=0x0, flags=flags@entry=3)
    at ex_docmd.c:1032
#7  0x00005555555f51ab in ex_execute (eap=0x7fffffffb890) at eval.c:7627
#8  0x000055555562581e in do_one_cmd (cookie=0x0, fgetline=0x0, cstack=0x7fffffffba40, 
    flags=11, cmdlinep=0x7fffffffb7f0) at ex_docmd.c:2620
#9  do_cmdline (cmdline=<optimized out>, fgetline=fgetline@entry=0x0, 
    cookie=cookie@entry=0x0, flags=flags@entry=11) at ex_docmd.c:1032
#10 0x0000555555626c9e in do_cmdline_cmd (cmd=<optimized out>) at ex_docmd.c:626
#11 0x00005555558110de in exe_commands (parmp=0x5555558ea880 <params>) at main.c:3173
#12 vim_main2 () at main.c:790
#13 0x00007ffff7a9dcd0 in __libc_start_call_main (main=main@entry=0x55555559a870 <main>, 
    argc=argc@entry=5, argv=argv@entry=0x7fffffffc278)
    at ../sysdeps/nptl/libc_start_call_main.h:58
#14 0x00007ffff7a9dd8a in __libc_start_main_impl (main=0x55555559a870 <main>, argc=5, 
    argv=0x7fffffffc278, init=<optimized out>, fini=<optimized out>, 
    rtld_fini=<optimized out>, stack_end=0x7fffffffc268) at ../csu/libc-start.c:360
#15 0x000055555559c345 in _start ()
strace logs

Notice how the last syscall only returns after killing the main process.

getpid()                                = 6778
newfstatat(AT_FDCWD, "!pty", 0x7fff20f70b60, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/dev/ptmx", O_RDWR|O_NOCTTY) = 5
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
rt_sigaction(SIGCHLD, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f15b61f8770}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
ioctl(5, TIOCGPTN, [3])                 = 0
ioctl(5, TIOCGPTN, [3])                 = 0
ioctl(5, TIOCSPTLCK, [0])               = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
rt_sigaction(SIGCHLD, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f15b61f8770}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f15b61f8770}, 8) = 0
openat(AT_FDCWD, "/dev/pts/3", O_RDWR|O_NOCTTY) = 7
close(7)                                = 0
ioctl(5, TCGETS, {c_iflag=ICRNL|IXON, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B38400|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|ECHOK|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
ioctl(5, TCGETS, {c_iflag=ICRNL|IXON, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B38400|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|ECHOK|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
ioctl(5, TIOCSWINSZ, {ws_row=24, ws_col=92, ws_xpixel=460, ws_ypixel=240}) = 0
fcntl(5, F_SETFL, O_RDONLY|O_NONBLOCK)  = 0
openat(AT_FDCWD, ".", O_RDONLY)         = 7
fchdir(7)                               = 0
chdir("/dev/pts")                       = 0
getcwd("/dev/pts", 4096)                = 9
fchdir(7)                               = 0
close(7)                                = 0
newfstatat(AT_FDCWD, "/dev/pts/3", {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x3), ...}, 0) = 0
openat(AT_FDCWD, ".", O_RDONLY)         = 7
fchdir(7)                               = 0
chdir("/dev/pts")                       = 0
getcwd("/dev/pts", 4096)                = 9
fchdir(7)                               = 0
close(7)                                = 0
newfstatat(AT_FDCWD, "/dev/pts/3", {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x3), ...}, 0) = 0
newfstatat(AT_FDCWD, "/dev/pts/3", {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x3), ...}, 0) = 0
readlink("/dev/pts/3", 0x7fff20f6fde0, 4095) = -1 EINVAL (Invalid argument)
newfstatat(AT_FDCWD, "/dev/pts/.3.swp", 0x7fff20f70e40, 0) = -1 ENOENT (No such file or directory)
write(1, "\r\"/dev/pts/3\" \33[51;14H\33[K", 25) = 25
newfstatat(AT_FDCWD, "/dev/pts/3", {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x3), ...}, 0) = 0
newfstatat(AT_FDCWD, "/dev/pts/3", {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x3), ...}, 0) = 0
openat(AT_FDCWD, "/dev/pts/3", O_WRONLY|O_APPEND) = 7
write(7, "\33[32mtexttexttext"..., 8192) = 8192
write(7, "texttext\n\33[32mtext"..., 8192) = 8192
write(7, "texttexttext"..., 8192) = 1220
--- SIGTERM {si_signo=SIGTERM, si_code=SI_USER, si_pid=6991, si_uid=1000} ---
rt_sigreturn({mask=[]})                 = 1220
write(7, "\n\33[m\33[32mtexttexttext\n"..., 6972) = ?
+++ killed by SIGKILL +++

@julio-b julio-b added the bug label Apr 22, 2024
@ronin49
Copy link
Contributor

ronin49 commented May 3, 2024

so maybe it's linux problem, not vim?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants