From dc204dd13700c1800a830a41fb22f10ab88fddb4 Mon Sep 17 00:00:00 2001 From: chrislu Date: Tue, 8 Mar 2022 23:02:30 -0800 Subject: [PATCH] fix nil entry panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x1d340b4] goroutine 130523 [running]: github.com/chrislusf/seaweedfs/weed/filer.FileSize(...) /code/seaweedfs/weed/filer/filechunks.go:26 github.com/chrislusf/seaweedfs/weed/mount.(*WFS).Lookup(0xc000866d80, 0x1, 0xc002897f40, {0xc004b00980, 0x39}, 0x1ec19e0) /code/seaweedfs/weed/mount/weedfs_dir_lookup.go:59 +0x654 github.com/hanwen/go-fuse/v2/fuse.doLookup(0xc00033c000, 0xc00033c000) /code/go/pkg/mod/github.com/hanwen/go-fuse/v2@v2.1.0/fuse/opcode.go:333 +0x6b github.com/hanwen/go-fuse/v2/fuse.(*Server).handleRequest(0xc000ab2420, 0xc00033c000) /code/go/pkg/mod/github.com/hanwen/go-fuse/v2@v2.1.0/fuse/server.go:483 +0x1f3 github.com/hanwen/go-fuse/v2/fuse.(*Server).loop(0xc000ab2420, 0x0) /code/go/pkg/mod/github.com/hanwen/go-fuse/v2@v2.1.0/fuse/server.go:456 +0x110 created by github.com/hanwen/go-fuse/v2/fuse.(*Server).readRequest /code/go/pkg/mod/github.com/hanwen/go-fuse/v2@v2.1.0/fuse/server.go:323 +0x534 --- weed/mount/weedfs_dir_lookup.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weed/mount/weedfs_dir_lookup.go b/weed/mount/weedfs_dir_lookup.go index 7f2821a94..02fc9f0d8 100644 --- a/weed/mount/weedfs_dir_lookup.go +++ b/weed/mount/weedfs_dir_lookup.go @@ -55,7 +55,7 @@ func (wfs *WFS) Lookup(cancel <-chan struct{}, header *fuse.InHeader, name strin inode := wfs.inodeToPath.Lookup(fullFilePath, localEntry.Mode, len(localEntry.HardLinkId) > 0, localEntry.Inode, true) - if fh, found := wfs.fhmap.FindFileHandle(inode); found { + if fh, found := wfs.fhmap.FindFileHandle(inode); found && fh.entry != nil { glog.V(4).Infof("lookup opened file %s size %d", dirPath.Child(localEntry.Name()), filer.FileSize(fh.entry)) localEntry = filer.FromPbEntry(string(dirPath), fh.entry) }