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

Non-UTF8 Characters Crash the Console #34

Closed
bmteller opened this issue Jun 9, 2020 · 2 comments
Closed

Non-UTF8 Characters Crash the Console #34

bmteller opened this issue Jun 9, 2020 · 2 comments
Assignees

Comments

@bmteller
Copy link
Contributor

bmteller commented Jun 9, 2020

Reproduce:

  1. Open Nerves Hub Console for a Device
  2. use Toolshed
  3. cmd("printf '\xaa'")
12:26:28.140 [error] GenServer NervesHubLink.Socket terminating
** (Jason.EncodeError) invalid byte 0xAA in <<170>>
    (jason 1.2.1) lib/jason.ex:150: Jason.encode!/2
    (phoenix_client 0.11.0) lib/phoenix_client/socket.ex:254: PhoenixClient.Socket.transport_send/2
    (phoenix_client 0.11.0) lib/phoenix_client/socket.ex:182: PhoenixClient.Socket.handle_info/2
    (stdlib 3.11.2) gen_server.erl:637: :gen_server.try_dispatch/4
    (stdlib 3.11.2) gen_server.erl:711: :gen_server.handle_msg/6
    (stdlib 3.11.2) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: :flush

12:26:33.141 [error] GenServer #PID<0.1495.0> terminating
** (stop) exited in: GenServer.call(#PID<0.1549.0>, {:push, "put_chars", %{data: <<170>>, encoding: :unicode}}, 5000)
    ** (EXIT) time out
    (elixir 1.10.2) lib/gen_server.ex:1023: GenServer.call/3
    (nerves_hub_link 0.8.2) lib/nerves_hub_link/console_channel.ex:200: NervesHubLink.ConsoleChannel.io_request/4
    (nerves_hub_link 0.8.2) lib/nerves_hub_link/console_channel.ex:107: NervesHubLink.ConsoleChannel.handle_info/2
    (stdlib 3.11.2) gen_server.erl:637: :gen_server.try_dispatch/4
    (stdlib 3.11.2) gen_server.erl:711: :gen_server.handle_msg/6
    (stdlib 3.11.2) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: {:io_request, #PID<0.1581.0>, #Reference<0.3180141690.537395201.92461>, {:put_chars, :unicode, <<170>>}}

12:26:34.971 [error] GenServer #PID<0.1595.0> terminating
** (MatchError) no match of right hand side value: nil
    (nerves_hub_link 0.8.2) lib/nerves_hub_link/console_channel.ex:91: NervesHubLink.ConsoleChannel.handle_info/2
    (stdlib 3.11.2) gen_server.erl:637: :gen_server.try_dispatch/4
    (stdlib 3.11.2) gen_server.erl:711: :gen_server.handle_msg/6
    (stdlib 3.11.2) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: %PhoenixClient.Message{channel_pid: #PID<0.1595.0>, event: "io_reply", join_ref: nil, payload: %{"data" => "cmd(\"ls\")", "kind" => "get_line"}, ref: nil, topic: "console"}

12:26:35.283 [warn]  Firmware stream error: "Unhandled Console handle_info - %PhoenixClient.Message{channel_pid: #PID<0.1597.0>, event: \"phx_reply\", join_ref: \"1\", payload: %{\"response\" => %{}, \"status\" => \"ok\"}, ref: \"2\", topic: \"console\"}"

12:26:35.284 [warn]  Firmware stream error: "unknown"

Then new consoles become unresponsive and if you keep on trying to open consoles then eventually the nerves hub link application crashes and the device is marked offline.

Example of nerves_hub_link eventually crashing on a device:

2020-06-09T13:00:45.180+01:00
device_id=PROD-006 [error] GenServer #PID<0.1568.0> terminating ** (stop) exited in: GenServer.call(#PID<0.1677.0>, {:push, "put_chars", %{data: <<9, 68, 97, 116, 97, 32, 115, 101, 114, 118, 105, 99, 101, 32, 99, 97, 112, 97, 98, 105, 108, 105, 116, 105, 101, 115, 58, 32, 39, 49, 39, 10, 9, 9, 91, 48, 93, 58, 32, 39, 108, 116, 101, 39, 10, 9, ...>>, encoding: :unicode}}, 5000) ** (EXIT) time out (elixir 1.10.3) lib/gen_server.ex:1023: GenServer.call/3 (nerves_hub_link 0.8.2) lib/nerves_hub_link/console_channel.ex:200: NervesHubLink.ConsoleChannel.io_request/4 (nerves_hub_link 0.8.2) lib/nerves_hub_link/console_channel.ex:107: NervesHubLink.ConsoleChannel.handle_info/2 (stdlib 3.11.2) gen_server.erl:637: :gen_server.try_dispatch/4 (stdlib 3.11.2) gen_server.erl:711: :gen_server.handle_msg/6 (stdlib 3.11.2) proc_lib.erl:249: :proc_lib.init_p_do_apply/3 Last message: {:io_request, #PID<0.1710.0>, #Reference<0.2557500624.537657345.219803>, {:put_chars, :unicode, <<9, 68, 97, 116, 97, 32, 115, 101, 114, 118, 105, 99, 101, 32, 99, 97, 112, 97, 98, 105, 108, 105, 116, 105, 101, 115, 58, 32, 39, 49, 39, 10, 9, 9, 91, 48, 93, 58, 32, 39, 108, 116, 101, ...>>}}

2020-06-09T13:01:19.170+01:00
device_id=PROD-006 [error] GenServer #PID<0.1861.0> terminating ** (MatchError) no match of right hand side value: nil (nerves_hub_link 0.8.2) lib/nerves_hub_link/console_channel.ex:91: NervesHubLink.ConsoleChannel.handle_info/2 (stdlib 3.11.2) gen_server.erl:637: :gen_server.try_dispatch/4 (stdlib 3.11.2) gen_server.erl:711: :gen_server.handle_msg/6 (stdlib 3.11.2) proc_lib.erl:249: :proc_lib.init_p_do_apply/3 Last message: %PhoenixClient.Message{channel_pid: #PID<0.1861.0>, event: "io_reply", join_ref: nil, payload: %{"data" => "ping \"google.com\", ifname: :wwan0", "kind" => "get_line"}, ref: nil, topic: "console"}

2020-06-09T13:01:19.245+01:00
device_id=PROD-006 [warn] Firmware stream error: "unknown"

2020-06-09T13:01:19.245+01:00
device_id=PROD-006 [warn] Firmware stream error: "Unhandled Console handle_info - %PhoenixClient.Message{channel_pid: #PID<0.1878.0>, event: \"phx_reply\", join_ref: \"1\", payload: %{\"response\" => %{}, \"status\" => \"ok\"}, ref: \"2\", topic: \"console\"}"

2020-06-09T13:01:23.246+01:00
device_id=PROD-006 [error] GenServer #PID<0.1878.0> terminating ** (MatchError) no match of right hand side value: nil (nerves_hub_link 0.8.2) lib/nerves_hub_link/console_channel.ex:91: NervesHubLink.ConsoleChannel.handle_info/2 (stdlib 3.11.2) gen_server.erl:637: :gen_server.try_dispatch/4 (stdlib 3.11.2) gen_server.erl:711: :gen_server.handle_msg/6 (stdlib 3.11.2) proc_lib.erl:249: :proc_lib.init_p_do_apply/3 Last message: %PhoenixClient.Message{channel_pid: #PID<0.1878.0>, event: "io_reply", join_ref: nil, payload: %{"data" => "", "kind" => "get_line"}, ref: nil, topic: "console"}

2020-06-09T13:01:23.329+01:00
device_id=PROD-006 [warn] Firmware stream error: "Unhandled Console handle_info - %PhoenixClient.Message{channel_pid: #PID<0.1883.0>, event: \"phx_reply\", join_ref: \"3\", payload: %{\"response\" => %{}, \"status\" => \"ok\"}, ref: \"4\", topic: \"console\"}"

2020-06-09T13:01:23.330+01:00
device_id=PROD-006 [warn] Firmware stream error: "unknown"

2020-06-09T13:01:23.457+01:00
device_id=PROD-006 [error] GenServer #PID<0.1883.0> terminating ** (MatchError) no match of right hand side value: nil (nerves_hub_link 0.8.2) lib/nerves_hub_link/console_channel.ex:91: NervesHubLink.ConsoleChannel.handle_info/2 (stdlib 3.11.2) gen_server.erl:637: :gen_server.try_dispatch/4 (stdlib 3.11.2) gen_server.erl:711: :gen_server.handle_msg/6 (stdlib 3.11.2) proc_lib.erl:249: :proc_lib.init_p_do_apply/3 Last message: %PhoenixClient.Message{channel_pid: #PID<0.1883.0>, event: "io_reply", join_ref: nil, payload: %{"data" => "", "kind" => "get_line"}, ref: nil, topic: "console"}

2020-06-09T13:01:23.529+01:00
device_id=PROD-006 [warn] Firmware stream error: "Unhandled Console handle_info - %PhoenixClient.Message{channel_pid: #PID<0.1886.0>, event: \"phx_reply\", join_ref: \"5\", payload: %{\"response\" => %{}, \"status\" => \"ok\"}, ref: \"6\", topic: \"console\"}"

2020-06-09T13:01:23.530+01:00
device_id=PROD-006 [warn] Firmware stream error: "unknown"

2020-06-09T13:01:23.641+01:00
device_id=PROD-006 [error] GenServer #PID<0.1886.0> terminating
** (MatchError) no match of right hand side value: nil
    (nerves_hub_link 0.8.2) lib/nerves_hub_link/console_channel.ex:91: NervesHubLink.ConsoleChannel.handle_info/2
    (stdlib 3.11.2) gen_server.erl:637: :gen_server.try_dispatch/4
    (stdlib 3.11.2) gen_server.erl:711: :gen_server.handle_msg/6
    (stdlib 3.11.2) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: %PhoenixClient.Message{channel_pid: #PID<0.1886.0>, event: "io_reply", join_ref: nil, payload: %{"data" => "", "kind" => "get_line"}, ref: nil, topic: "console"}

2020-06-09T13:01:23.650+01:00
device_id=PROD-006 [info] Application nerves_hub_link exited: shutdown
@fhunleth
Copy link
Contributor

@bmteller Thanks for reporting this. It doesn't seem like anyone has time to look into this now. There is a plan for completely replacing the shell with a terminal.js-based one (or something similar). As you can imagine, pretty much all of the code in this area would be replaced. I don't know the time frame. If get time and figure out a fix for this, I'm sure that we'd take it.

@fhunleth
Copy link
Contributor

This "works" on the newly deployed console:

image

It certainly fixes the issue of nerves_hub_link crashing. The problem is now with Toolshed.cmd/1 being picky about Unicode output.

If you want to try, the new console is available in the main branch. We haven't made an official release yet, but will likely make one in the next week.

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

No branches or pull requests

3 participants