apache / apache/nuttx

Hardfault on boot with telnet daemon without dev console

Open
#4,443 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
4k
Forks
1.7k
Avg merge
1d 17h
Merged PRs (30d)
237

Description

CONFIG_NETUTILS_TELNETD=y
CONFIG_DEV_CONSOLE=n
CONFIG_DEBUG_FEATURES=n
This will lead to hardfault.

Telnet daemon here create a socket. Without dev console fd of socket is set to 0
https://github.com/apache/incubator-nuttx-apps/blob/c222043ed1ede9ef8e9e93ffed14ee9c41c4a2b1/netutils/telnetd/telnetd_daemon.c#L158-L160
Then if CONFIG_DEBUG_FEATURES not defined 0 fd will be closed, while closing default first 3 streams.
https://github.com/apache/incubator-nuttx-apps/blob/c222043ed1ede9ef8e9e93ffed14ee9c41c4a2b1/netutils/telnetd/telnetd_daemon.c#L226
So next accept will be called on closed socket and leads to hardfault
https://github.com/apache/incubator-nuttx-apps/blob/c222043ed1ede9ef8e9e93ffed14ee9c41c4a2b1/netutils/telnetd/telnetd_daemon.c#L240

I suppose it is NuttX bug rather than telnet daemon app and probably related to #2203 and #2263.

I'm testing this inside px4 firmware on most latest master after moving to 10.1.0+ NuttX. Custom board, stm32f7.
I suppose closed px4 board for tests is fmu-v5x. @davids5 FYI.
CONFIG_DEBUG_FEATURES=y fix the hardfault, but there is no nsh on usb (I'm calling `nshterm /dev/ttyACM0 &`). It works if there is dev serial console, I don't check where is the source of problem.
(to compile px4 with CONFIG_DEBUG_FEATURES=y fixing format strings patch is needed https://github.com/apache/incubator-nuttx/pull/4441)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.