[BUG] testing/sched/timerjitter: unexpected results under normal usage
- Dominant language
- C
- Stars
- 465
- Forks
- 779
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 36
Description
### Description / Steps to reproduce the issue
Found while testing apps/testing/sched/timerjitter on QEMU RISC-V (rv-virt), NuttX-13.0.0-RC2. All three reproduce under normal, non-adversarial usage. A separate off-by-one in the sample loop was already
fixed in [pull#3629](https://github.com/apache/nuttx-apps/pull/3629)
1. avg: nan with default args
```c
nsh> timerjitter
timer jitter in 0 run:
(latency/us) min: 4294967295, avg: nan, max 0
```
Running with no arguments at all completes 0 iterations and prints avg: nan. Should the default guarantee at least 1 iteration, or otherwise avoid printing nan?
2. Very large missed-frame counts, one run did not finish
```c
nsh> timerjitter 100 5
time frame missed 1
...
time frame missed 17363
timer jitter in 5 run:
(latency/us) min: 3129, avg: 347295, max 1269743
```
Another run with the same arguments printed missed-frame lines continuously and never completed; it had to be terminated externally:
```c
nsh> timerjitter 100 5
time frame missed 1
...
time frame missQEMU: Terminated
```
3. Negative jitter shown as a huge unsigned value
```c
nsh> timerjitter 10000 10
time frame missed 1
timer jitter in 10 run:
(latency/us) min: 4294966445, avg: 1010, max 12854
```
4294966445 = 2^32 - 851. avg in the same run is a small, plausible number, while min is not — suggesting min/max end up holding a negative value that gets displayed as a large unsigned one.
### On which OS does this issue occur?
[OS: Linux]
### What is the version of your OS?
Ubuntu 20.04
### NuttX Version
master
### Issue Architecture
[Arch: all]
### Issue Area
[Area: Testing]
### Host information
Environment
- Board/config: boards/risc-v/qemu-rv/rv-virt/configs/knsh_romfs, running on QEMU
- CONFIG_USEC_PER_TICK changed from the board's default (1000) back to the Kconfig default 10000
### Verification
- [x] I have verified before submitting the report.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the apps/testing/sched/timerjitter entry point and reproduce the three cases on QEMU RISC-V with the arguments shown: no arguments, 100 5, and 10000 10. Trace how iterations, missed frames, and jitter extrema are calculated and printed. Done means the reported runs complete reliably, avoid invalid NaN or wrapped values, and preserve meaningful latency results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- embedded-iot, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100