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

current master ttyd crash #491

Closed
rchernobelskiy opened this issue Sep 23, 2020 · 3 comments
Closed

current master ttyd crash #491

rchernobelskiy opened this issue Sep 23, 2020 · 3 comments
Labels

Comments

@rchernobelskiy
Copy link

Describe the bug
using the latest image, ttyd crashes when exit on frontend

To Reproduce

docker run -it --rm -p7681:7681 tsl0922/ttyd:latest

Then load up localhost:7681 and press ctrl+D and ctrl+shift+R repeatedly for a few minutes

Expected behavior
A clear and concise description of what you expected to happen.

Additional context
I think this commit introduced it: f9d23de

@cfraenkel
Copy link

I recompiled the image with debug flags and got the following backtrace from a core dump ( 11 (SEGV)):

(gdb) bt
#0  0x000000000040408b in child_cb (handle=0x7efc2982b1c0, signum=17) at /ttyd/src/protocol.c:139
#1  0x000000000044957f in uv__signal_event (loop=0x7efc2982bc20, w=0x7efc2982be50, events=1) at src/unix/signal.c:459
#2  0x00000000004518c2 in uv__io_poll (loop=0x7efc2982bc20, timeout=4994) at src/unix/linux-core.c:438
#3  0x0000000000441988 in uv_run (loop=0x7efc2982bc20, mode=UV_RUN_DEFAULT) at src/unix/core.c:381
#4  0x00000000004311d3 in elops_run_pt_uv ()
#5  0x0000000000417796 in lws_service ()
#6  0x0000000000402975 in main (argc=5, argv=0x7ffd0e5402b8) at /ttyd/src/server.c:553

here's the log at debug level 10

[2020/10/23 12:56:22:4681] I: Initial logging level 10
[2020/10/23 12:56:22:4682] I: Libwebsockets version: 4.0.20 unknown-build-hash
[2020/10/23 12:56:22:4682] I: IPV6 compiled in but disabled
[2020/10/23 12:56:22:4682] I:  LWS_DEF_HEADER_LEN    : 4096
[2020/10/23 12:56:22:4682] I:  LWS_MAX_SMP           : 1
[2020/10/23 12:56:22:4682] I:  sizeof (*info)        : 680
[2020/10/23 12:56:22:4682] I:  SYSTEM_RANDOM_FILEPATH: '/dev/urandom'
[2020/10/23 12:56:22:4682] I:  HTTP2 support         : not configured
[2020/10/23 12:56:22:4682] I: context created
[2020/10/23 12:56:22:4682] I: Using event loop: libuv
[2020/10/23 12:56:22:4682] I: Default ALPN advertisment: http/1.1
[2020/10/23 12:56:22:4682] I:  default timeout (secs): 20
[2020/10/23 12:56:22:4682] I:  Threads: 1 each 1048576 fds
[2020/10/23 12:56:22:4682] I:  mem: context:          7840 B (3744 ctx + (1 thr x 4096))
[2020/10/23 12:56:22:4682] I:  mem: http hdr size:   (20480 + 864), max count 16
[2020/10/23 12:56:22:4724] I:  mem: pollfd map:      8388608 B
[2020/10/23 12:56:22:4767] I:  mem: platform fd map: 8388608 B
[2020/10/23 12:56:22:4767] I:  Compiled with OpenSSL support
[2020/10/23 12:56:22:4768] I:  SSL disabled: no LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT
[2020/10/23 12:56:22:4768] I:  canonical_hostname = 8767427104c8
[2020/10/23 12:56:22:4768] I:  mem: per-conn:          560 bytes + protocol rx buf
[2020/10/23 12:56:22:4768] I: lws_cancel_service
[2020/10/23 12:56:22:4768] I: Creating Vhost 'default' port 7681, 2 protocols, IPv6 off
[2020/10/23 12:56:22:4769] I: lws_state_notify_protocol_init: doing protocol init on POLICY_VALID
[2020/10/23 12:56:22:4769] I: lws_protocol_init
[2020/10/23 12:56:22:4769] I: lws_plat_drop_app_privileges: not changing group
[2020/10/23 12:56:22:4769] I: lws_plat_drop_app_privileges: not changing user
[2020/10/23 12:56:22:4769] I: lws_state_transition_steps: CONTEXT_CREATED -> OPERATIONAL
[2020/10/23 12:56:29:7379] I: lws_header_table_attach: wsi 0x7efc2982aab0: ah 0 (tsi 0, count = 0) in
[2020/10/23 12:56:29:7380] I: _lws_create_ah: created ah 0x7efc28820480 (size 20480): pool length 1
[2020/10/23 12:56:29:7380] I: lws_header_table_attach: did attach wsi 0x7efc2982aab0: ah 0x7efc28820480: count 1 (on exit)
[2020/10/23 12:56:29:7380] I: lws_header_table_attach: wsi 0x7efc2982ad50: ah 0 (tsi 0, count = 1) in
[2020/10/23 12:56:29:7380] I: _lws_create_ah: created ah 0x7efc28820890 (size 20480): pool length 2
[2020/10/23 12:56:29:7380] I: lws_header_table_attach: did attach wsi 0x7efc2982ad50: ah 0x7efc28820890: count 2 (on exit)
[2020/10/23 12:56:29:7380] I: lws_buflist_aware_read: wsi 0x7efc2982aab0: lws_h1_server_socket_service: ssl_capable_read 572
[2020/10/23 12:56:29:7381] I: lws_handshake_server: parsed count 572
[2020/10/23 12:56:29:7381] I: lws_select_vhost: vhost match to default based on port 7681
[2020/10/23 12:56:29:7381] I: lws_handshake_server: 0x7efc2982aab0: No upgrade
[2020/10/23 12:56:29:7381] I: Method: 'GET' (0), request for '/'
[2020/10/23 12:56:29:7381] I: no hit
[2020/10/23 12:56:29:7381] I: lws_add_http_header_content_length: wsi 0x7efc2982aab0: tx_content_length/remain 112249
[2020/10/23 12:56:29:7381] I: lws_issue_raw: ssl_capable_write (143) says 143
[2020/10/23 12:56:29:7382] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:7383] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:7383] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:7383] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:7383] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:7383] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:7700] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:7701] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:7701] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:7701] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:7701] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:7701] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:7701] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:7701] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:8102] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:8103] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:8103] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:8103] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:8104] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:8104] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:8104] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:8104] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:8104] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:8104] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:8104] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:8105] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:8105] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:29:8105] I: lws_issue_raw: ssl_capable_write (1657) says 1657
[2020/10/23 12:56:29:8105] I: lws_http_transaction_completed: wsi 0x7efc2982aab0
[2020/10/23 12:56:29:8105] I: __lws_header_table_detach: wsi 0x7efc2982aab0: ah 0x7efc28820480 (tsi=0, count = 2)
[2020/10/23 12:56:29:8105] I: __lws_header_table_detach: nobody usable waiting
[2020/10/23 12:56:29:8105] I: _lws_destroy_ah: freed ah 0x7efc28820480 : pool length 1
[2020/10/23 12:56:29:8105] I: __lws_header_table_detach: wsi 0x7efc2982aab0: ah 0x7efc28820480 (tsi=0, count = 1)
[2020/10/23 12:56:29:9620] I: lws_header_table_attach: wsi 0x7efc2982aab0: ah 0 (tsi 0, count = 1) in
[2020/10/23 12:56:29:9620] I: _lws_create_ah: created ah 0x7efc28820c00 (size 20480): pool length 2
[2020/10/23 12:56:29:9621] I: lws_header_table_attach: did attach wsi 0x7efc2982aab0: ah 0x7efc28820c00: count 2 (on exit)
[2020/10/23 12:56:29:9621] I: lws_buflist_aware_read: wsi 0x7efc2982aab0: lws_h1_server_socket_service: ssl_capable_read 437
[2020/10/23 12:56:29:9621] I: lws_handshake_server: parsed count 437
[2020/10/23 12:56:29:9621] I: lws_select_vhost: vhost match to default based on port 7681
[2020/10/23 12:56:29:9621] I: lws_handshake_server: 0x7efc2982aab0: No upgrade
[2020/10/23 12:56:29:9621] I: Method: 'GET' (0), request for '/token'
[2020/10/23 12:56:29:9621] I: no hit
[2020/10/23 12:56:29:9621] I: lws_add_http_header_content_length: wsi 0x7efc2982aab0: tx_content_length/remain 13
[2020/10/23 12:56:29:9622] I: lws_issue_raw: ssl_capable_write (136) says 136
[2020/10/23 12:56:29:9622] I: lws_issue_raw: ssl_capable_write (13) says 13
[2020/10/23 12:56:29:9622] I: lws_http_transaction_completed: wsi 0x7efc2982aab0
[2020/10/23 12:56:29:9622] I: __lws_header_table_detach: wsi 0x7efc2982aab0: ah 0x7efc28820c00 (tsi=0, count = 2)
[2020/10/23 12:56:29:9622] I: __lws_header_table_detach: nobody usable waiting
[2020/10/23 12:56:29:9622] I: _lws_destroy_ah: freed ah 0x7efc28820c00 : pool length 1
[2020/10/23 12:56:29:9623] I: __lws_header_table_detach: wsi 0x7efc2982aab0: ah 0x7efc28820c00 (tsi=0, count = 1)
[2020/10/23 12:56:30:0782] I: lws_header_table_attach: wsi 0x7efc2881f050: ah 0 (tsi 0, count = 1) in
[2020/10/23 12:56:30:0782] I: _lws_create_ah: created ah 0x7efc28820c10 (size 20480): pool length 2
[2020/10/23 12:56:30:0782] I: lws_header_table_attach: did attach wsi 0x7efc2881f050: ah 0x7efc28820c10: count 2 (on exit)
[2020/10/23 12:56:30:0782] I: lws_buflist_aware_read: wsi 0x7efc2881f050: lws_h1_server_socket_service: ssl_capable_read 650
[2020/10/23 12:56:30:0783] I: lws_handshake_server: parsed count 650
[2020/10/23 12:56:30:0783] I: lws_select_vhost: vhost match to default based on port 7681
[2020/10/23 12:56:30:0783] I: Upgrade to ws
[2020/10/23 12:56:30:0783] I: lws_issue_raw: ssl_capable_write (158) says 158
[2020/10/23 12:56:30:0784] I: _lws_validity_confirmed_role: wsi 0x7efc2881f050: setting validity timer 300s (hup 0)
[2020/10/23 12:56:30:0784] I: lws_process_ws_upgrade2: 0x7efc2881f050: dropping ah on ws upgrade
[2020/10/23 12:56:30:0784] I: __lws_header_table_detach: wsi 0x7efc2881f050: ah 0x7efc28820c10 (tsi=0, count = 2)
[2020/10/23 12:56:30:0784] I: __lws_header_table_detach: nobody usable waiting
[2020/10/23 12:56:30:0784] I: _lws_destroy_ah: freed ah 0x7efc28820c10 : pool length 1
[2020/10/23 12:56:30:0784] I: __lws_header_table_detach: wsi 0x7efc2881f050: ah 0x7efc28820c10 (tsi=0, count = 1)
[2020/10/23 12:56:30:1140] I: lws_ws_frame_rest_is_payload: using 16 of raw input (total 16 on offer)
[2020/10/23 12:56:30:1152] I: lws_issue_raw: ssl_capable_write (22) says 22
[2020/10/23 12:56:30:1152] I: lws_issue_raw: ssl_capable_write (6) says 6
[2020/10/23 12:56:30:1185] I: lws_ws_frame_rest_is_payload: using 26 of raw input (total 26 on offer)
[2020/10/23 12:56:30:1545] I: lws_issue_raw: ssl_capable_write (49) says 49
[2020/10/23 12:56:33:8090] I: lws_header_table_attach: wsi 0x7efc2982aab0: ah 0 (tsi 0, count = 1) in
[2020/10/23 12:56:33:8090] I: _lws_create_ah: created ah 0x7efc28820c00 (size 20480): pool length 2
[2020/10/23 12:56:33:8091] I: lws_header_table_attach: did attach wsi 0x7efc2982aab0: ah 0x7efc28820c00: count 2 (on exit)
[2020/10/23 12:56:33:8091] I: lws_buflist_aware_read: wsi 0x7efc2982aab0: lws_h1_server_socket_service: ssl_capable_read 572
[2020/10/23 12:56:33:8091] I: lws_handshake_server: parsed count 572
[2020/10/23 12:56:33:8091] I: lws_select_vhost: vhost match to default based on port 7681
[2020/10/23 12:56:33:8091] I: lws_handshake_server: 0x7efc2982aab0: No upgrade
[2020/10/23 12:56:33:8091] I: Method: 'GET' (0), request for '/'
[2020/10/23 12:56:33:8091] I: no hit
[2020/10/23 12:56:33:8092] I: lws_add_http_header_content_length: wsi 0x7efc2982aab0: tx_content_length/remain 112249
[2020/10/23 12:56:33:8092] I: lws_issue_raw: ssl_capable_write (143) says 143
[2020/10/23 12:56:33:8093] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8093] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8093] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8093] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8093] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8093] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8093] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8093] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8093] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8093] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8093] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8093] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8094] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8094] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8094] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8094] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8094] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8094] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8094] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8094] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8094] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8094] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8094] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8094] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8094] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8094] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8402] I: lws_issue_raw: ssl_capable_write (4096) says 4096
[2020/10/23 12:56:33:8468] I: lws_issue_raw: ssl_capable_write (1657) says 1657
[2020/10/23 12:56:33:8468] I: lws_http_transaction_completed: wsi 0x7efc2982aab0
[2020/10/23 12:56:33:8468] I: __lws_header_table_detach: wsi 0x7efc2982aab0: ah 0x7efc28820c00 (tsi=0, count = 2)
[2020/10/23 12:56:33:8468] I: __lws_header_table_detach: nobody usable waiting
[2020/10/23 12:56:33:8468] I: _lws_destroy_ah: freed ah 0x7efc28820c00 : pool length 1
[2020/10/23 12:56:33:8468] I: __lws_header_table_detach: wsi 0x7efc2982aab0: ah 0x7efc28820c00 (tsi=0, count = 1)
[2020/10/23 12:56:33:8525] I: lws_issue_raw: ssl_capable_write (4) says 4
[2020/10/23 12:56:33:8525] I: __lws_close_free_wsi: 0x7efc2881f050: caller: close_and_handled
[2020/10/23 12:56:33:8525] I: 0x7efc2881f050: end LRS_FLUSHING_BEFORE_CLOSE
[2020/10/23 12:56:33:8525] I: __lws_close_free_wsi: shutdown conn: 0x7efc2881f050 (sk 14, state 0x11e)
[2020/10/23 12:56:33:8525] I: __lws_close_free_wsi: 0x7efc2881f050: caller: close_and_handled uv repeat test
[2020/10/23 12:56:33:8525] I: lws_libuv_closewsi: 0x7efc2881f050
[2020/10/23 12:56:33:8525] I: lws_libuv_closewsi: sa left 2: dyn left: 4 (rk 0)

Dockerfile:

FROM tsl0922/musl-cross
RUN git clone --depth=1 https://github.com/tsl0922/ttyd.git /ttyd \
    && cd ttyd && sed -i -e "s/CMAKE_BUILD_TYPE=RELEASE/CMAKE_BUILD_TYPE=Debug/" -e "s/-Wl,-s//" -e "s/-Os/-O0/" ./scripts/cross-build.sh \
    && env BUILD_TARGET=x86_64 WITH_SSL=true ./scripts/cross-build.sh

FROM ubuntu:18.04
COPY --from=0 /ttyd/build/ttyd /usr/bin/ttyd

ADD https://github.com/krallin/tini/releases/download/v0.18.0/tini /sbin/tini
RUN chmod +x /sbin/tini

EXPOSE 7681

ENTRYPOINT ["/sbin/tini", "--"]
CMD ["ttyd", "bash"]

@tsl0922
Copy link
Owner

tsl0922 commented Nov 7, 2020

Reproduced with the latest docker image which was compiled with musl libc, but can't reproduce it with local glibc build.

@tsl0922
Copy link
Owner

tsl0922 commented Dec 27, 2020

Should be fixed on master now (5650606).

@tsl0922 tsl0922 closed this as completed Dec 27, 2020
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

3 participants