Skip to content

[bug][P1] session_id 用 wrapping_add — u64 回绕时旧 session 误匹配 #297

Description

@appergb

现象

coordinator.rs line 1071:

state.session_id = state.session_id.wrapping_add(1);

只检查 id 相等就匹配 RecorderError 等迟到事件。

风险

理论上 u64 在单进程寿命内 2^64 次回绕几乎不可能,但 wrapping_add 不会 panic / 报错;如果某天真发生:

  • 旧 session 的 RecorderError 误匹配到新 session(id 数值相同)
  • 错误中止 active 的新 session

建议

  • debug_assert!(state.session_id != 0) 验证非饥饿场景
  • 或用 checked_add + log::warn! 在边界条件可见
  • 长期方案:用 UUID 替代单调递增 u64(彻底消除碰撞)

来源

docs/audit-2026-05-06.md §1.4 高风险 #3

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions