Skip to content

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

@appergb

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpriority: highHigh priority

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions