Root cause: update_for_append() returned Ok(0) when new_size <= old_size, leaving a stale mmap that would SIGBUS on access.
Fix: Introduced AppendStatus enum (Unchanged/Appended/Reloaded). When file shrinks, reload() rebuilds the mmap and line index. TUI layer clamps cursor and invalidates viewport on Reloaded, matching existing handle_file_truncated() behavior.
Fixed in b6e655b.
Root cause: `update_for_append()` returned `Ok(0)` when `new_size <= old_size`, leaving a stale mmap that would SIGBUS on access.
Fix: Introduced `AppendStatus` enum (`Unchanged`/`Appended`/`Reloaded`). When file shrinks, `reload()` rebuilds the mmap and line index. TUI layer clamps cursor and invalidates viewport on `Reloaded`, matching existing `handle_file_truncated()` behavior.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
文件:
core/io/file_reader.rs:116分类: 内存安全
问题:
update_for_append()检测到new_size <= old_size时直接返回Ok(0),不重新 mmap。如果文件被截断/轮转,后续访问旧 mmap 范围会触发 SIGBUS 进程崩溃。影响: log viewer 场景下文件经常被外部轮转/截断,但代码假设文件在 mmap 期间不变。
建议修复: 检测
new_size < old_size时强制reload()或返回错误要求重新映射/索引。Fixed in
b6e655b.Root cause:
update_for_append()returnedOk(0)whennew_size <= old_size, leaving a stale mmap that would SIGBUS on access.Fix: Introduced
AppendStatusenum (Unchanged/Appended/Reloaded). When file shrinks,reload()rebuilds the mmap and line index. TUI layer clamps cursor and invalidates viewport onReloaded, matching existinghandle_file_truncated()behavior.