tsl0922 / ttyd

Share your terminal over the web
https://tsl0922.github.io/ttyd
MIT License
8.02k stars 880 forks source link

ttyd hangs at 100% CPU when uploading a file #766

Closed avshalomt closed 2 years ago

avshalomt commented 3 years ago

Describe the bug When I try to upload a ~60KB file using ZModem (apt install lrzsz && rs -evb), the client and the server hangs.

To Reproduce Steps to reproduce the behavior:

  1. Browse to an Ubuntu machine's ttyd server from Chrome
  2. Upload a binary ~60KB file using rs -evb
  3. The client will hang, and the server process will freeze at 100% CPU usage.

Expected behavior The upload should succeed (or fail with a clear message).

Screenshots The server log says:

ttyd 1.6.3-07ad8be (libwebsockets 2.0.3)
....
[2021/09/12 16:40:32:5820] ERR: lws_rx_sm: doing draining flow
[2021/09/12 16:40:32:5820] NOTICE: WS closed from 172.16.11.87, clients: 0
[2021/09/12 16:40:32:5820] NOTICE: killing process, pid: 19798
[2021/09/12 16:40:32:5824] NOTICE: process killed with signal 1, pid: 19798

And then the client prints: [ttyd] websocket connection closed with code: 1006 So it's unclear who really closes the WS, because each side says it's the other one.

Environment:

The server seems to have a segmentation fault in libwebsockets, but it never dies. The server didn't respond to ignore kill -SIGTERM and also seems to ignore SIGSEGV (As I see a segmentation fault in GDB but it's still alive), and could only be killed with a SIGKILL signal.

image image

tsl0922 commented 2 years ago

libwebsockets < 3.2.0 is not supported anymore, try the latest version.