Skip to content

Fix TaskRunner::addTask registering every task twice - #56

Merged
kevin-f-ortega merged 3 commits into
fprime-community:mainfrom
nathancheek:fix-taskrunner-double-add
Oct 14, 2026
Merged

kevin-f-ortega merged 3 commits into
fprime-community:mainfrom
nathancheek:fix-taskrunner-double-add

Conversation

@nathancheek

Copy link
Copy Markdown
Contributor

See nasa/fprime#5815

#42 added a shift-based insert but kept the old lines that first write the task to m_task_table[m_index], so every task was placed twice and ran twice per round. Destroying a task left a dangling duplicate in the table.

This PR solves that by removing the extra m_task_table insertion. It also switches to a different method of counting the number of tasks. m_index is used to point to the next task to run, so this variable can't be relied upon for calculating the number of tasks if tasks have already started running.

I added UTs to show that these issues are resolved. Also added an SDD to include the unit test requirements.

Claude AI was used during investigation, bugfixing, unit test writing, and documentation.

task to m_task_table[m_index], so every task was placed twice and ran twice
per round. Destroying a task left a dangling duplicate in the table.

Count tasks by finding the first empty slot rather than using m_index, since
m_index is the run cursor. Insert each task once. Add a TaskRunner SDD and
randomized unit tests.

Fixes fprime-community#30
@thomas-bc

Copy link
Copy Markdown
Member

@Iva-L would you be able to help us review this?

@Iva-L Iva-L left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, great catch! Just a minor change for safety. I verified it with fprime-stm32-baremetal-reference :

  • Current main, flashed and run: taskRunner.m_task_table shows all 18 tasks duplicated.
  • Same board, rebuilt with this PR's fix: m_task_table shows exactly 18 unique entries.

@Iva-L Iva-L left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I don't know if @kevin-f-ortega has anything else to review?

@kevin-f-ortega kevin-f-ortega left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a minor update to this PR

@kevin-f-ortega

Copy link
Copy Markdown
Contributor

And great catch @nathancheek !

@kevin-f-ortega
kevin-f-ortega merged commit 6685537 into fprime-community:main Oct 14, 2026
1 check passed
@nathancheek
nathancheek deleted the fix-taskrunner-double-add branch October 15, 2026 06:05
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 this pull request may close these issues.

4 participants