Lxc-attach: Long output stops suddenly, possible bug?

Hi,

I have a Proxmox host where I am running several LXC AlmaLinux 8 containers. I tried debugging this so I made sure to only use lxc tools (and not pct enter as example)

I observed following problem:

When I enter the container with lxc-attach and read a file that has long output, the output suddenly stops. It also does not stop consistently at the same line. When you cat the file again, you get a little bit more lines. Never less lines.

Before I open a GitHub issue I wanted to ask, if someone can reproduce this or even knows this problem?

In order to reproduce the issue, please do the follwing:

  1. SSH to your host.

  2. Create a basic LXC container ( as example, use the basic AlmaLinux 8 container template from Proxmox, http://download.proxmox.com/images/system/almalinux-8-default_20210928_amd64.tar.xz)

  3. Enter the container with lxc-attach ID

  4. Run this bash command in order to create a file with a lot of lines:

for i in {1..100000}; do echo "$i:abcdefghijklmnopqrstuvwxyz1234567890"; done > output.txt
  1. Afterwards, basically cat the file:
cat /root/output.txt

For me, the output suddenly ends like this:

6714:abcdefghijklmnopqrstuvwxyz1234567890
6715:abcdefghijklmnopqrstuvwxyz1234567890
6716:abcdefghijklmnopqrstuvwxyz1234567890
6717:abcdefghijklmnopqrstuvwxyz1234567890
6718:abcdefghijklmnopqrstuvwxy

If I do the cat command again, I get more lines, at this time I ended at 7086:

7081:abcdefghijklmnopqrstuvwxyz1234567890
7082:abcdefghijklmnopqrstuvwxyz1234567890
7083:abcdefghijklmnopqrstuvwxyz1234567890
7084:abcdefghijklmnopqrstuvwxyz1234567890
7085:abcdefghijklmnopqrstuvwxyz1234567890
7086:abcdefghijklmnopqrstuvwxyz1234567890

Then again:

7957:abcdefghijklmnopqrstuvwxyz1234567890
7958:abcdefghijklmnopqrstuvwxyz1234567890
7959:abcdefghijklmnopqrstuvwxyz1234567890

I have no idea how to debug or troubleshoot this, I also tried doing a log file:

lxc-attach 10000 -o /root/10000.log -l DEBUG

lxc-attach 10000 20241105120705.143 WARN     terminal - ../src/lxc/terminal.c:lxc_terminal_ptx_io:357 - Short write on terminal r:838 != w:-1
lxc-attach 10000 20241105120705.143 WARN     terminal - ../src/lxc/terminal.c:lxc_terminal_ptx_io:357 - Short write on terminal r:1024 != w:-1
lxc-attach 10000 20241105120705.143 WARN     terminal - ../src/lxc/terminal.c:lxc_terminal_ptx_io:357 - Short write on terminal r:778 != w:-1
lxc-attach 10000 20241105120705.143 WARN     terminal - ../src/lxc/terminal.c:lxc_terminal_ptx_io:357 - Short write on terminal r:266 != w:-1
lxc-attach 10000 20241105120705.143 WARN     terminal - ../src/lxc/terminal.c:lxc_terminal_ptx_io:357 - Short write on terminal r:836 != w:-1
lxc-attach 10000 20241105120705.143 WARN     terminal - ../src/lxc/terminal.c:lxc_terminal_ptx_io:357 - Short write on terminal r:704 != w:-1
lxc-attach 10000 20241105120705.143 WARN     terminal - ../src/lxc/terminal.c:lxc_terminal_ptx_io:357 - Short write on terminal r:1024 != w:-1
lxc-attach 10000 20241105120705.143 WARN     terminal - ../src/lxc/terminal.c:lxc_terminal_ptx_io:357 - Short write on terminal r:669 != w:-1
lxc-attach 10000 20241105120705.143 WARN     terminal - ../src/lxc/terminal.c:lxc_terminal_ptx_io:357 - Short write on terminal r:991 != w:-1
lxc-attach 10000 20241105120705.143 WARN     terminal - ../src/lxc/terminal.c:lxc_terminal_ptx_io:357 - Short write on terminal r:792 != w:-1
lxc-attach 10000 20241105120705.143 WARN     terminal - ../src/lxc/terminal.c:lxc_terminal_ptx_io:357 - Short write on terminal r:528 != w:-1
lxc-attach 10000 20241105120705.143 WARN     terminal - ../src/lxc/terminal.c:lxc_terminal_ptx_io:357 - Short write on terminal r:177 != w:-1
lxc-attach 10000 20241105120705.144 WARN     terminal - ../src/lxc/terminal.c:lxc_terminal_ptx_io:357 - Short write on terminal r:17 != w:-1

Does anyone know this issue or can even reproduce this?

Thank you!

I can confirm this problem.

OS: Debian 12/Proxmox Virtual Environment 8.3.2
lxc-attach --version: 6.0.0

It does not depend on the OS inside the container (confirmed with Debian, Alpine and Arch).

This does not happen always.
With your bash test script I sometimes get all 100000 lines of output and sometimes not.

(This error is the reason why my Ansible playbooks sometimes fail, because I use an LXC-connection-plugin (GitHub - andreasscherbaum/ansible-lxc-ssh: Ansible connection plugin using ssh + lxc-attach) and the Ansible setup module produces long JSON-Output.)

Did you ever found a solution or opened an issue somewhere?

Has anyone an idea how to do further debugging?