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

ESP32S3 usbnsh hang on ps command #12712

Closed
no1wudi opened this issue Jul 16, 2024 · 6 comments · Fixed by #12716
Closed

ESP32S3 usbnsh hang on ps command #12712

no1wudi opened this issue Jul 16, 2024 · 6 comments · Fixed by #12716

Comments

@no1wudi
Copy link
Contributor

no1wudi commented Jul 16, 2024

When using usbnsh, I find that it frequently hangs:

NuttShell (NSH) NuttX-12.5.1
nsh> 
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 002000 nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 002000 nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 002000 nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 002000 nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 002000 nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 002000 nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 002000 nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 002000 nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 002000 nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 002000 nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 002000 nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 002000 nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 

I'm tested with boards/xtensa/esp32s3/esp32s3-devkit/configs/usbnsh, this issue is easy to reproduce by type ps multiple times.

@no1wudi no1wudi changed the title ESP32C3 usbnsh hang on ps command ESP32S3 usbnsh hang on ps command Jul 16, 2024
@acassis
Copy link
Contributor

acassis commented Jul 16, 2024

@tmedicci @eren-terzioglu @fdcavalcanti please take a look

@w2016561536
Copy link
Contributor

I met this kind of bug too. This bug could be triggered after some heavy load such as coremark.

@pkarashchenko
Copy link
Contributor

pkarashchenko commented Jul 16, 2024

I met similar some time ago. In my case the default stack was configured to too small value. Setting default task stack to 4K fixed the issue. Here I see the stack is set to 8K, so that should not be an issue. Would be good to enable stack coloration to see the % of stack consumption.

@pkarashchenko
Copy link
Contributor

Ups. Just checked the code and was confused by 002000 interpreting this as hex value, but found %06lu is code. So still can be default stack size issue

@pkarashchenko
Copy link
Contributor

Maybe worth of changing %06lu to %6lu that will remove prefixed zeroes for decimal value...

@no1wudi
Copy link
Contributor Author

no1wudi commented Jul 17, 2024

I met similar some time ago. In my case the default stack was configured to too small value. Setting default task stack to 4K fixed the issue. Here I see the stack is set to 8K, so that should not be an issue. Would be good to enable stack coloration to see the % of stack consumption.

Thanks, it's the same issue:

NuttShell (NSH) NuttX-12.5.1
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 001744  43.0%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 001888  46.6%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002000  49.4%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002000  49.4%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002032  50.1%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002128  52.5%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002128  52.5%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002128  52.5%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002128  52.5%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002128  52.5%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002128  52.5%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002128  52.5%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002128  52.5%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002128  52.5%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002128  52.5%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002128  52.5%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002128  52.5%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002128  52.5%  nsh_main
nsh> ops
nsh: ops: command not found
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002128  52.5%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002128  52.5%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002128  52.5%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002208  54.5%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002208  54.5%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002208  54.5%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002208  54.5%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002208  54.5%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002208  54.5%  nsh_main
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK           STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread   - Ready              0000000000000000 003056 000592  19.3%  Idle_Task
    1     1 100 RR       Task      - Running            0000000000000000 004048 002208  54.5%  nsh_main
nsh> 

It won't hang if I increase the stack size for nsh.

no1wudi added a commit to no1wudi/nuttx that referenced this issue Jul 17, 2024
Fix apache#12712

If run nsh over usb based serial port, the default stack size is too small,
for example simple `ps` command will use more than 2208 bytes stack.

Then the stack overflow will happen and the system will hang here.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
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

Successfully merging a pull request may close this issue.

4 participants