-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Description
Describe the bug
Some extra discussion about the issue can be found in PR #67596, basically telnet shell asserts if telnet connection is closed.
If asserts are disabled no visible error was seen, but according to the code in
zephyr/subsys/shell/shell_ops.c
Line 425 in 11f7fa2
| void z_shell_write(const struct shell *sh, const void *data, |
the internal variables in the
z_shell_write() could contain invalid values which could corrupt internal state of the shell.
To Reproduce
Setup the network by executing tools/net-tools/net-setup.sh that is found in net-tools zephyr project.
west build -p -b native_sim samples/net/telnet/ -d ../build/telnet \
-t run -- -DCONFIG_ASSERT=y -DCONFIG_NATIVE_UART_0_ON_STDINOUT=y \
-DCONFIG_LOG_BACKEND_UART=y -DCONFIG_SHELL_LOG_BACKEND=n
and then execute echo x | telnet 192.0.2.1 from the host.
Expected behavior
The telnet connection is closed without any errors / crashes.
Impact
If the asserts are enabled, the crashing of the system is not necessary as we just closed the connection.
If the asserts are disabled, the internal state of the shell might cause corruption.
Logs and console output
*** Booting Zephyr OS build zephyr-v3.5.0-4132-gf37d150c1052 ***
uart:~$ ASSERTION FAIL [err == 0] @ WEST_TOPDIR/zephyr/subsys/shell/shell_ops.c:438
@ WEST_TOPDIR/zephyr/lib/os/assert.c:43
Exiting due to fatal error
Environment (please complete the following information):
- OS: Linux
- Commit SHA or Version used: zephyr-v3.5.0-4132-gf37d150c1052