InfiniTimeOrg / InfiniTimeOrg/InfiniSim

SIGFPE (division by zero) in random number app

Open
#160 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
203
Forks
97
PR merge metrics
No merged PRs in 30d

Description

Enter the random number app.
Click the "generate random number" button, or one of the "+" or "-" buttons, a few times.
Most of the times, this will stop the simulator process with a SIGFPE due to a division by zero in InfiniTime/src/components/motion/MotionController.cpp, function MotionController::ShouldShakeWake, because time == lastTime

This looks like having time == lastTime could be a simulator bug, not an issue on actual hardware, not sure.

Here's the patch I have applied locally to InfiniTime; let me know if you think it should go to InfiniTime (cleaned up of debugging output to cerr, obviously) for better robustness or is just a work-around for a simulator bug.

InfiniTime_FPE.zip

(sorry I upload it as a ZIP file, github doesn't let me attach a patch file with a messaging listing the supported file types, among which "PATCH")

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the crash in the random number app, then inspect InfiniTime/src/components/motion/MotionController.cpp and MotionController::ShouldShakeWake, focusing on the time == lastTime case. Review the attached InfiniTime_FPE.zip patch and determine whether the guard belongs in InfiniTime or only works around a simulator issue. Done means repeated random-number generation no longer terminates the simulator with SIGFPE.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
embedded-iot
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.