Closed
【缺陷报告】数据类型截断 - 文件utils.cpp - 函数TimestampToTime - 行号841 #948
zhangjunkai9Add on Sep 9Closed at Sep 17
Sep 9 Assign zhuliangying as responsible person
Sep 9 Removed responsible person zhuliangying
Sep 9 Assign chenminghao11 as responsible person
xiangyang0909
Sep 9 Comments:
Sep 9 Comments:
问题确认。这里在取余前将完整时间戳转换为 uint32_t,丢失高位,导致采集起止信息中 collectionDateBegin/End 的微秒小数错误。建议先使用 64 位时间戳取余,再转换结果,并补充精确校验小数部分的 UT。
影响描述需稍作调整:原始 collectionTimeBegin/End 仍保留正确时间戳,目前确认的是可读时间的转换错误。另外,“超过 2^32 后每次必错”不够准确,存在截断前后余数恰好 相同的情况。


komorebi
Sep 9 Comments:
Sep 9 Comments:
收到,预计在9.17日前处理


Sep 15 Associated pull request
komorebi
Sep 17 Comments:
Sep 17 Comments:
已修复


Sep 17 changed custom state from 进行中 to 已完成
Sep 17 Close issue
Sep 17 Added label: resolved
缺陷信息
缺陷描述
TimestampToTime 用于将微秒级时间戳字符串转为可读时间:第840行 secTime 用完整 64 位 stoll 值除以 unit 计算秒(正确),但第841行 microTime = static_cast<uint32_t>(std::stoll(timestamp)) % static_cast<uint32_t>(unit) 先把 64 位时间戳截断为 32 位再取模。所有调用方传入的都是 epoch 微秒级时间戳(Utils::GetHostTime 返回 tv_sec*1000000+tv_usec,约 1.7e15,utils.cpp:1578;调用点 prof_task.cpp:140/143、ctrl_files_dumper.cpp:41/44、msprof_task.cpp:152/155 均以 unit=TIME_US=1000000 调用),远超 2^32,因此每次调用微秒部分都被计算为错误值:(ts mod 2^32) mod 10^6 ≠ ts mod 10^6,采集起止时间(collectionDateBegin/End)的小数部分完全错误。entry_callchain 误指向 avp 模块的 C 版本同名函数(utils.c:384,uint64_t 直传、无此缺陷),经自主探索确认 C++ 版本存在多处真实调用路径,属每次调用必现的真实缺陷。
事实核查
数据流证据
传播路径:
调用链
可达调用链1 起点:
(entry functions)→ 终点:TimestampToTime深度:4修复建议
secTime = std::stoll(timestamp) / unit; microTime = static_cast<uint32_t>(std::stoll(timestamp) % static_cast<int64_t>(unit));