[BUG] Empty core affinity mask strands a ready task and permanently starves lower priority tasks (configRUN_MULTIPLE_PRIORITIES 0)
维护者通常 3 天内回复
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 15/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- c
调研方向
The relevant code is prvSelectHighestPriorityTask() in tasks.c, which handles ready-list selection and uxTopReadyPriority, and the affinity setters vTaskCoreAffinitySet() and the xTaskCreate*AffinitySet functions, which store the mask without validating it. Read how the selection loop skips tasks whose affinity excludes the current core, then reproduce with configNUMBER_OF_CORES 2 and configRUN_MULTIPLE_PRIORITIES 0. Done means either the zero mask is rejected at the API or the top-priority pin no longer starves eligible lower-priority tasks. The reporter says a fix is already prepared, so check for linked work before starting.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
vTaskCoreAffinitySet() and xTaskCreateAffinitySet()/xTaskCreateStaticAffinitySet() store the mask unconditionally. A zero mask is accepted (task.h documents no non-zero precondition; no configASSERT rejects it) and makes the task ready but runnable on no core.
With configRUN_MULTIPLE_PRIORITIES 0 (the FreeRTOS.h default) the selection drop rule in prvSelectHighestPriorityTask() then pins uxTopReadyPriority on that task's ready list (the list is non-empty, so the top priority is not decremented), and every selection falls back to the idle tasks (uxCurrentPriority = tskIDLE_PRIORITY when below the top). Lower-priority tasks that are ready and eligible on every core are permanently starved while the system idles.
Target
- Development board: any SMP target (reproduced on a POSIX host-port harness with
configNUMBER_OF_CORES 2,configRUN_MULTIPLE_PRIORITIES 0,configUSE_CORE_AFFINITY 1) - Instruction Set Architecture: host arm64 reproduction
- Toolchain and version: clang (host), FreeRTOS-Kernel
8be86d4a2
To Reproduce
Public APIs only. The mask is producible by a caller computing an allowed-core set dynamically (e.g. after offlining the last eligible core):
- Create tasks; set one task's mask to 0 via
vTaskCoreAffinitySet( handle, 0 )(or create withxTaskCreateAffinitySet(..., 0, ...)). - Observe: the task stays
eReadybut never runs; every other task below its priority freezes (progress counters flat in the harness window while idle iterations run into the millions); only idle tasks run.
Control: the identical run with a valid non-empty mask keeps making progress.
Expected behavior
- An empty mask should be rejected or ignored at the API (a
configASSERTplus a documented non-zero precondition is the usual pattern; note asserts compile out in release builds, so an always-on guard is preferable here). prvSelectHighestPriorityTask()must not pinuxTopReadyPriorityon a ready list containing only tasks that are runnable on no core - no core can ever select from such a list, and leaving it pinned starves eligible tasks at lower priorities.
Additional context
- Related but different: PR #1264 (closed, unmerged) publicly describes only the idle-absence -> stuck-
SCHEDULED_TO_YIELDspin (tracked in a separate follow-up issue). #1086/PR #1123 fixed a different affinity mechanism (missing re-select after affinity change). - A fix with regression tests is prepared; PRs will reference this issue.
- 主要语言
- C
- 星标
- 4.6k
- 派生
- 1.6k
- 平均合并
- 2 天 22 小时
- 30 天内合并 PR
- 4
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
FreeRTOS/FreeRTOS-Kernel 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
FreeRTOS/FreeRTOS-Kernel#1542 ·
维护者通常 3 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
FreeRTOS/FreeRTOS-Kernel#1520 ·
维护者通常 3 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 62/100
FreeRTOS/FreeRTOS-Kernel#1494 · 3 条评论 ·
维护者通常 3 天内回复
-
enhancement
难度 5/5 一周以上 新手友好度 25/100
FreeRTOS/FreeRTOS-Kernel#1554 ·
维护者通常 3 天内回复
-
[BUG] event_wait_timed can't return false可能已有人在做 @TedLyngmo 于 39 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 38/100
FreeRTOS/FreeRTOS-Kernel#1546 ·
维护者通常 3 天内回复
查看 FreeRTOS/FreeRTOS-Kernel 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
shinyquagsire23/OpenJKDF2#540 ·
维护者通常 12 天内回复
-
Prison work hall: laundry and kitchen stations stand at bare walls, the hatch has no counter or sign未关闭
难度 2/5 1-3 小时 新手友好度 78/100
Life-Framework/Life-Framework#5939 ·
维护者通常 1 天内回复
-
autoconf failes to find libsodium even when present due to implicit function declaration可能已有人在做 @coderjoe 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 13 天内回复
-
Bug Status: Needs Triage
难度 1/5 1 小时以内 新手友好度 74/100
维护者通常 1 天内回复
-
bug python
难度 2/5 1-3 小时 新手友好度 87/100
Jstar269/nakagawa-recomp#3521 ·
维护者通常 1 天内回复