#3937·cadvisor

fs/vfs: GetVfsStats 超时时与写入命名返回值发生竞争

作者: thc1006创建于 2026年9月26日更新于 2026年9月26日

`GetVfsStats` (`lib/fs/vfs/stats.go`) runs `statfs` in a goroutine and returns `ctx.Err()` after two seconds. The goroutine assigns the named results (`err` at line 46, `total` to `inodesFree` at lines 49 to 53), and the timeout branch at line 59 writes the same variables on its way out. When the timeout path returns without receiving the worker's result, those two sets of writes are not synchronized. The buffered `resultChan` keeps the goroutine from blocking after the caller has returned, but it does nothing to order those writes against the timeout return.

内容来源: google/cadvisor