Skip to content

[Bug] LocalFS.StatFile panics on non-ENOENT stat errors #25602

Closed

Description

@Ariznawlll

Summary

LocalFS.StatFile can panic on filesystem errors other than ENOENT because it dereferences a nil os.FileInfo after os.Stat returns an error.

Reproduction

At commit 7821d21c723372e45a8f65da3bbb896a157b1036:

  1. Create a regular file at root/a.
  2. Call LocalFS.StatFile("a/b").

os.Stat returns an ENOTDIR error and a nil stat, after which pkg/fileservice/local_fs.go:972-977 calls stat.IsDir(). The process panics instead of returning the filesystem error. The same pattern applies to other non-ENOENT errors.

Expected

Any os.Stat error should be returned (with ENOENT mapped to FileNotFound) before dereferencing stat.

Activity

  1. added
    kind/bug
    ai-light
    and removed
    ai-light
    on Jul 11, 2026
  2. added this to the MO-202607 milestone on Jul 11, 2026
  3. added theissue type on Jul 11, 2026
  4. removed
    kind/bug
    on Jul 11, 2026
  5. added
    kind/bug
    severity/s0
    and removed on Jul 12, 2026
  6. LeftHandCold commented on Jul 15, 2026

    @LeftHandCold
    Collaborator

    fixed

  7. Ariznawlll commented on Jul 15, 2026

    @Ariznawlll
    CollaboratorAuthor

    最新 main 详细验证

    • 源码基线:origin/main@f1c0a92d882dbdad469ffd2c96f607796207c797。
    • 执行命令:
    go test ./pkg/fileservice \
      -run '^Test(DiskObjectStorageWriteFailureRemovesTempFile|DiskObjectStorageSizeMismatchRemovesTempFile|DiskObjectStorageDeleteReturnsRemovalError|LocalFSStatFileReturnsNonNotExistError)$' \
      -count=3 -v

    本 issue 对应测试过程

    1. 在 LocalFS 根目录创建普通文件 file。
    2. 对 file/child 调用 StatFile,制造“中间路径不是目录”的 OS 错误。
    3. 断言返回的是 syscall.ENOTDIR,而不是被错误归一化成 os.ErrNotExist。

    结果

    • TestLocalFSStatFileReturnsNonNotExistError:PASS 3/3。
    • package:ok github.com/matrixorigin/matrixone/pkg/fileservice 0.461s。
    • 结论:非 NotExist 的 stat 错误在最新 main 可正确透传。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions