🟡 [M18] reset_vm_hwm 非权限错误被吞导致内存峰值污染无提示 #38
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
问题
warn_reset_hwm()只在PermissionDenied时打印 warning,其他 I/O 错误被静默忽略。影响
当
/proc不可用、容器限制或内核不支持相关接口时,VmHWM 无法重置,但用户不知道,跨 suite 的峰值内存数据可能被污染。位置
crates/bench/src/runner.rs:11建议
对所有
reset_vm_hwm()错误输出 warning;权限错误可保留专门文案,其他错误输出通用失败原因。修复方案
commit
e945a35变更内容
runner.rs
reset_vm_hwm()错误现在都会输出 warning(不再仅限PermissionDenied)PermissionDenied保留 "Try running as root" 专属提示AtomicBoolwarn-once 机制,7 次 suite 调用只打印 1 次警告warn_reset_hwm()改为pub,供 main.rs 预检共享使用main.rs
can_reset_vm_hwm()(笼统 "no root") 改为调用warn_reset_hwm()metrics.rs
can_reset_vm_hwm()死代码测试
hwm_warned_flag_prevents_reentry— 验证 flag 去重逻辑warn_reset_hwm_does_not_panic— 验证多次调用安全性验证
cargo check✅cargo test(53 tests) ✅cargo clippy无新增 warning ✅