-
Notifications
You must be signed in to change notification settings - Fork 82
fix: NativeDayMerge makeDayRecord 未设置 reserved 字段导致非 linux/amd64 平台 volume 虚高 100 倍#105
Merged
Merged
fix: NativeDayMerge makeDayRecord 未设置 reserved 字段导致非 linux/amd64 平台 volume 虚高 100 倍 #105jing2uo merged 1 commit into
jing2uo merged 1 commit into
Conversation
This was referenced Jun 5, 2026
digiprospector
pushed a commit
to digiprospector/tdx2db
that referenced
this pull request
Jun 6, 2026
PR jing2uo#105 给 makeDayRecord 补了 reserved = 0x10000(TDX 正常记录标记), 但原测试仍断言 reserved == 0——这正是 volume 虚高 100 倍的根因被固化 成了"期望行为",会让 CI 挂掉。 改为断言 reserved == 0x10000,并增加端到端校验:写出的 volume 经 parseVolumeOverflow 读回后不应被 ×ばつ100。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
在非 linux/amd64 平台(macOS、Windows)上,cron 通过 NativeDayMerge 写入 .day 文件时,
makeDayRecord 使用 make([]byte, recordSize) 创建缓冲区(全零初始化),
导致 reserved 字段(bytes 28-31)为 0x00000000。
parseVolumeOverflow 判断 reserved != 0x10000 时走溢出分支,执行 volRaw ×ばつ 100,
最终写入数据库的 volume 虚高 100 倍,turnover 同步虚高。
现象
以 sh600000 为例:
原因
TDX .day 文件约定:reserved == 0x10000 表示正常记录,其他值触发溢出解码(×ばつ 100)。
makeDayRecord 写入新记录时未显式设置 reserved,导致误判为溢出记录。
修复
写入 reserved = 0x10000,与 TDX 原始 .day 文件格式保持一致。